This is simple flutter toggle button widget.
Supports show text labels and icons, Possible set multiple value to toggle ui, not only 2 values.
Also you can customize size and colors as you like.
Screenshot of SampleApp
- Toggle Items
- Provide toggle change event.
- Show texts
- Show icons
- Customization of Size, And colors when toggle on/off.
Add this to your package's pubspec.yaml file:
dependencies:
fk_toggle: ^0.1.1
You can install packages from the command line with Flutter:
$ flutter pub get
Import in your project:
import 'package:fk_toggle/fk_toggle.dart';
Scaffold(
appBar: AppBar(title: const Text('Sample Toggle Switches')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: Padding(
padding: const EdgeInsets.all(10.0),
child: FkToggle(
width: 50,
height: 30,
labels: const ['1', '2']
),
)
)
),
),
);
Property name | description | default value | required |
---|---|---|---|
width | length of a toogle |
🈚 | ✔️ |
height | height of widget | 🈚 | ✔️ |
labels | toggle button texts. Allow empty text | 🈚 | ✔️ |
cornerRadius | size of corner radius | 10 | |
backgroundColor | unselected toggle color | Colors.black26 | |
selectedColor | selected toggle color | Colors.blue | |
disabledElementColor | unselected label color | Colors.black54 | |
enabledElementColor | selected label color | Colors.white | |
fontSize | font size of labels | 16.0 | |
icons | Allow null value in lists,You can set an icon for any Toggle | 🈚 | |
onSelected | provide toggle change event, Provide index and instance | 🈚 |
- Implement animation feature
- Improve class paramters to about like auto calulate width and height.
- you can post some issues.
Feel free to send message.
Welcome to work consultation or everything.
Twitter:@fukutan_org
github:fukutan-org