@@ -40,7 +40,7 @@ Follow these steps to use this package
4040
4141``` yaml
4242dependencies :
43- group_button : ^4.8.0 # latest version
43+ group_button : ^5.0.0
4444` ` `
4545
4646### Add import package
@@ -56,30 +56,11 @@ Put this code in your project at an screen and learn how it works 😊
5656``` dart
5757GroupButton(
5858 isRadio: false,
59- spacing: 10,
6059 onSelected: (index, isSelected) => print('$index button is selected'),
6160 buttons: ["12:00", "13:00", "14:30", "18:00", "19:00", "21:40"],
6261)
6362```
6463
65- ### Can't easier to use
66- Now you can use even simpler constructors to build your button groups. <br >
67- Example for a group with a single value selection
68- ``` dart
69- GroupButton.radio(
70- buttons: ['12:00', '13:00', '14:00'],
71- onSelected: (i) => debugPrint('Button $i selected'),
72- )
73- ```
74-
75- Example for a group with a choice of multiple values
76- ``` dart
77- GroupButton.checkbox(
78- buttons: ['12:00', '13:00', '14:00'],
79- onSelected: (i, selected) => debugPrint('Button $i selected: $selected'),
80- )
81- ```
82-
8364### Controller
8465** Starting from version 4.1.0** <br >
8566You can control your Group Button using the controller
@@ -102,59 +83,66 @@ Column(
10283),
10384```
10485
86+ ### Generic button value
87+ In new 5.0.0 version you can set custom buttons value type <br >
88+ It can be int, DateTime, double or YourCustomClass <br >
89+ Button text will be result of .toString() model method in common button display case <br >
90+ ``` dart
91+ GroupButton<DateTime>(
92+ buttons: [DateTime(2022, 4, 9), DateTime(2022, 4, 10)],
93+ )
94+ ```
95+
96+ Also you can use generic button values with cutsom buttonBuilder <br >
97+ In order to turn values into any widget
98+ ``` dart
99+ GroupButton<DateTime>(
100+ buttons: [DateTime(2022, 4, 9), DateTime(2022, 4, 10)],
101+ buttonBuilder: (selected, date, context) {
102+ return Text('${date.year}-${date.month}-${date.day}');
103+ },
104+ ),
105+ ```
106+
105107### Customize
106- In order to customize your buttons inside * GroupButton* you can use code below</br >
107- This code includes * all* the fields used in * GroupButton*
108+ In order to customize your buttons inside * GroupButton* you can use * GroupButtonOptions*
108109
109110``` dart
110- GroupButton(
111- controller: GroupButtonController(),
112- spacing: 5,
113- isRadio: false,
114- groupingType: GroupingType.wrap,
115- direction: Axis.horizontal,
116- onSelected: (index, isSelected) => debugPrint(
117- '$index button is ${isSelected ? 'selected' : 'unselected'}',
118- ),
119- buttons: const [
120- "Dart",
121- "Kotlin",
122- "Java",
123- "Swift",
124- "Objective-C",
125- "Python",
126- "JS",
127- "C#",
128- "C",
129- "C++"
130- ],
131- selectedButtons: const [1, 2, 3],
132- selectedTextStyle: const TextStyle(
133- fontWeight: FontWeight.w600,
134- fontSize: 16,
135- color: Colors.red,
111+ GroupButtonOptions(
112+ selectedShadow: const [],
113+ selectedTextStyle: TextStyle(
114+ fontSize: 20,
115+ color: Colors.pink[900],
136116 ),
117+ selectedColor: Colors.pink[100],
118+ unselectedShadow: const [],
119+ unselectedColor: Colors.amber[100],
137120 unselectedTextStyle: TextStyle(
138- fontWeight: FontWeight.w600,
139- fontSize: 14,
140- color: Colors.grey[600],
121+ fontSize: 20,
122+ color: Colors.amber[900],
141123 ),
142- selectedColor: Colors.white,
143- unselectedColor: Colors.grey[300],
144- selectedBorderColor: Colors.red,
145- unselectedBorderColor: Colors.grey[500],
146- borderRadius: BorderRadius.circular(5.0),
147- selectedShadow: const <BoxShadow>[BoxShadow(color: Colors.transparent)],
148- unselectedShadow: const <BoxShadow>[BoxShadow(color: Colors.transparent)],
149- buttonHeight: 30,
150- buttonWidth: 115,
151- enableDeselect: false,
152- maxSelected: 5
153- );
124+ selectedBorderColor: Colors.pink[900],
125+ unselectedBorderColor: Colors.amber[900],
126+ borderRadius: BorderRadius.circular(100),
127+ spacing: 10,
128+ runSpacing: 10,
129+ groupingType: GroupingType.wrap,
130+ direction: Axis.horizontal,
131+ buttonHeight: 60,
132+ buttonWidth: 60,
133+ mainGroupAlignment: MainGroupAlignment.start,
134+ crossGroupAlignment: CrossGroupAlignment.start,
135+ groupRunAlignment: GroupRunAlignment.start,
136+ textAlign: TextAlign.center,
137+ textPadding: EdgeInsets.zero,
138+ alignment: Alignment.center,
139+ elevation: 0,
140+ ),
154141```
155142
156- ### Examples
143+ ![ ] ( https://github.com/Frezyx/group_button/blob/master/example/rep_files/options_example.png?raw=true )
157144
145+ ### Examples
158146You can check more examples of using this package [ here] ( example/lib )
159147
160148<br >
0 commit comments