11import 'package:flutter/material.dart' ;
22
3+ /// A builder for custom confirmation widget
34typedef Widget SmartSelectOptionConfirmationBuilder (
45 BuildContext context, Function onConfirm);
6+
7+ /// A builder for custom option group header widget
58typedef Widget SmartSelectOptionGroupHeaderBuilder (String _group, int _count);
9+
10+ /// A builder for custom divider widget between option item
611typedef Widget SmartSelectOptionDividerBuilder (BuildContext context, int index);
12+
13+ /// A builder for custom each option item widget
714typedef Widget SmartSelectOptionItemBuilder (
815 Map item, bool checked, SmartSelectOptionItemOnChange onChange);
16+
17+ /// Callback to handle change of each custom option item
918typedef void SmartSelectOptionItemOnChange (dynamic value, bool checked);
1019
20+ /// List of option along with its configuration
1121class SmartSelectOption {
22+
23+ /// The list of object option items
1224 final List items;
25+
26+ /// Custom property from each option item
27+ /// that represent the label
1328 final String label;
29+
30+ /// Custom property from each option item
31+ /// that represent the value
1432 final String value;
33+
34+ /// Custom property from each option item
35+ /// that used to grouped option items
1536 final String groupBy;
37+
38+ /// Whether show the options list
39+ /// as single choice or multiple choice
1640 final bool isMultiChoice;
41+
42+ /// Whether the options list modal use header or not
1743 final bool useHeader;
44+
45+ /// Whether the option list is filterable or not
1846 final bool useFilter;
19- final bool useDivider;
47+
48+ /// Whether the option list need to confirm
49+ /// to return the changed value
2050 final bool useConfirmation;
51+
52+ /// Whether the option item use divider or not
53+ final bool useDivider;
54+
55+ /// Modal border shape
56+ /// used in popup dialog and bottom sheet
2157 final ShapeBorder shape;
58+
59+ /// Modal elevation
60+ /// used in popup dialog and bottom sheet
2261 final double elevation;
62+
63+ /// Modal background color
2364 final Color backgroundColor;
65+
66+ /// Custom color of the glowing indicator
67+ /// when overscroll the option list
2468 final Color glowingOverscrollIndicatorColor;
69+
70+ /// Configure option header theme
2571 final SmartSelectOptionHeaderTheme headerTheme;
72+
73+ /// Configure option item theme
2674 final SmartSelectOptionItemTheme itemTheme;
75+
76+ /// Configure option group header theme
2777 final SmartSelectOptionGroupHeaderTheme groupHeaderTheme;
78+
79+ /// Builder for each custom option item
2880 final SmartSelectOptionItemBuilder itemBuilder;
81+
82+ /// Builder for custom divider widget between option item
2983 final SmartSelectOptionDividerBuilder dividerBuilder;
84+
85+ /// Builder for custom confirmation widget
3086 final SmartSelectOptionConfirmationBuilder confirmationBuilder;
87+
88+ /// Builder for custom option group header widget
3189 final SmartSelectOptionGroupHeaderBuilder groupHeaderBuilder;
3290
91+ /// Create list of option along with its configuration
3392 SmartSelectOption (
3493 this .items, {
3594 this .label = 'label' ,
@@ -53,6 +112,7 @@ class SmartSelectOption {
53112 this .groupHeaderBuilder,
54113 });
55114
115+ /// return a filtered list of options
56116 List filteredList (String _query) {
57117 return _query != null
58118 ? items.where ((_item) => _filterTest (_item, _query)).toList ()
@@ -74,27 +134,48 @@ class SmartSelectOption {
74134 : false ;
75135 }
76136
137+ /// return a list of group keys
77138 List groupKeys (List _items) {
78139 Set _groups = Set ();
79140 _items.forEach ((_item) => _groups.add (_item[groupBy]));
80141 return _groups.toList ();
81142 }
82143
144+ /// return a list of group items
83145 List groupItems (List _items, String key) {
84146 return _items.where ((_item) => _item[groupBy] == key).toList ();
85147 }
86148}
87149
150+ /// Configure modal option header theme
88151class SmartSelectOptionHeaderTheme {
152+
153+ /// Header border shape
89154 final ShapeBorder shape;
155+
156+ /// Header elevation
90157 final double elevation;
158+
159+ /// Header background color
91160 final Color backgroundColor;
161+
162+ /// Header brightness
92163 final Brightness brightness;
164+
165+ /// Whether the header title is centered
93166 final bool centerTitle;
167+
168+ /// Header text style
169+ /// used by title and search field
94170 final TextStyle textStyle;
171+
172+ /// Header icon theme
95173 final IconThemeData iconTheme;
174+
175+ /// Header actions icon theme
96176 final IconThemeData actionsIconTheme;
97177
178+ /// Create a configuration of modal option header theme
98179 const SmartSelectOptionHeaderTheme ({
99180 this .shape,
100181 this .elevation = 0.5 ,
@@ -107,12 +188,22 @@ class SmartSelectOptionHeaderTheme {
107188 });
108189}
109190
191+ /// Configure option item theme
110192class SmartSelectOptionItemTheme {
193+
194+ /// Checked icon color
111195 final Color checkColor;
196+
197+ /// Checkbox or radio active color
112198 final Color activeColor;
199+
200+ /// Unselected checkbox or radio color
113201 final Color unselectedColor;
202+
203+ /// Option item text style
114204 final TextStyle titleStyle;
115205
206+ /// Create a configuration of option item theme
116207 const SmartSelectOptionItemTheme ({
117208 this .checkColor = Colors .white,
118209 this .activeColor = Colors .black54,
@@ -121,15 +212,25 @@ class SmartSelectOptionItemTheme {
121212 });
122213}
123214
215+ /// Configure option group header theme
124216class SmartSelectOptionGroupHeaderTheme {
217+
218+ /// Group header background color
125219 final Color backgroundColor;
126- final TextStyle titleStyle;
220+
221+ /// Group header text style
222+ final TextStyle textStyle;
223+
224+ /// Group header padding
127225 final EdgeInsetsGeometry padding;
226+
227+ /// Group header height
128228 final double height;
129229
230+ /// Create a configuration of option group header theme
130231 const SmartSelectOptionGroupHeaderTheme ({
131232 this .backgroundColor = const Color (0xFFECEFF1 ),
132- this .titleStyle = const TextStyle (color: Colors .black54),
233+ this .textStyle = const TextStyle (color: Colors .black54),
133234 this .padding = const EdgeInsets .symmetric (horizontal: 16.0 ),
134235 this .height = 45.0 ,
135236 });
0 commit comments