11# smart_select
22
3- Smart select allows you to easily convert your usual form selects to dynamic pages with grouped radio or checkbox inputs. This widget is inspired by Smart Select component from [ Framework7] ( https://framework7.io/ ) .
3+ Smart select allows you to easily convert your usual form selects into dynamic pages with various choices input. This widget is inspired by Smart Select component from [ Framework7] ( https://framework7.io/ ) .
4+
5+ # Demo
6+
7+ [ ![ Demo App] ( https://github.com/davigmacode/flutter_smart_select/tree/master/example/art/qr/apk.png " Demo App ")] ( https://github.com/davigmacode/flutter_smart_select/tree/master/example/art/demo/SmartSelect.apk )
48
59# Features
610
711* Select single or multiple choice
8- * Open options in page, bottom sheet, or popup dialog
9- * Grouping options with sticky header
10- * Customizable trigger widget
11- * Customizable options item widget
12- * Customizable label, value, and group field
13- * Filterable option item
12+ * Open choices modal in full page, bottom sheet, or popup dialog
13+ * Various choices input (radio, checkbox, switch, chips)
14+ * Grouping choices with sticky header
15+ * Customizable trigger widget (tile)
16+ * Customizable modal style
17+ * Customizable modal header style
18+ * Customizable choices style
19+ * Customizable option input
20+ * Filterable option
21+ * Async option
22+ * and many more
1423
1524# TODO
1625
17- * Use chip as option item
18- * Support dark mode
26+ * Full support async option using Future
1927
2028# Usage
2129
@@ -28,17 +36,17 @@ To read more about classes and other references used by `smart_select`, see the
2836```
2937String value = 'flutter';
3038List options = [
31- { 'value': 'ionic', 'label ': 'Ionic' },
32- { 'value': 'flutter', 'label ': 'Flutter' },
33- { 'value': 'react', 'label ': 'React Native' },
39+ { 'value': 'ionic', 'title ': 'Ionic' },
40+ { 'value': 'flutter', 'title ': 'Flutter' },
41+ { 'value': 'react', 'title ': 'React Native' },
3442];
3543
3644@override
3745Widget build(BuildContext context) {
3846 return SmartSelect(
3947 title: 'Frameworks',
4048 value: value,
41- option: SmartSelectOption (options),
49+ option: SmartSelectOptionConfig (options),
4250 onChange: (val) => setState(() => value = val),
4351 );
4452}
@@ -49,44 +57,44 @@ Widget build(BuildContext context) {
4957```
5058List value = ['flutter'];
5159List options = [
52- { 'value': 'ionic', 'label ': 'Ionic' },
53- { 'value': 'flutter', 'label ': 'Flutter' },
54- { 'value': 'react', 'label ': 'React Native' },
60+ { 'value': 'ionic', 'title ': 'Ionic' },
61+ { 'value': 'flutter', 'title ': 'Flutter' },
62+ { 'value': 'react', 'title ': 'React Native' },
5563];
5664
5765@override
5866Widget build(BuildContext context) {
5967 return SmartSelect(
6068 title: 'Frameworks',
6169 value: value,
62- option: SmartSelectOption(
63- options,
64- isMultiChoice: true,
65- ),
70+ isMultiChoice: true,
71+ option: SmartSelectOptionConfig(options),
6672 onChange: (val) => setState(() => value = val),
6773 );
6874}
6975```
7076
71- ## Open in Page
77+ ## Open in Full Page
7278
73- By default SmartSelect open options in page.
79+ By default SmartSelect open choices modal in full page.
7480
7581```
7682String value = 'flutter';
7783List options = [
78- { 'value': 'ionic', 'label ': 'Ionic' },
79- { 'value': 'flutter', 'label ': 'Flutter' },
80- { 'value': 'react', 'label ': 'React Native' },
84+ { 'value': 'ionic', 'title ': 'Ionic' },
85+ { 'value': 'flutter', 'title ': 'Flutter' },
86+ { 'value': 'react', 'title ': 'React Native' },
8187];
8288
8389@override
8490Widget build(BuildContext context) {
8591 return SmartSelect(
8692 title: 'Frameworks',
8793 value: value,
88- option: SmartSelectOption(options),
89- target: SmartSelectTarget.page,
94+ option: SmartSelectOptionConfig(options),
95+ modal: SmartSelectModalConfig(
96+ type: SmartSelectModalType.fullPage,
97+ ),
9098 onChange: (val) => setState(() => value = val),
9199 );
92100}
@@ -97,17 +105,20 @@ Widget build(BuildContext context) {
97105```
98106String value = 'flutter';
99107List options = [
100- { 'value': 'ionic', 'label ': 'Ionic' },
101- { 'value': 'flutter', 'label ': 'Flutter' },
102- { 'value': 'react', 'label ': 'React Native' },
108+ { 'value': 'ionic', 'title ': 'Ionic' },
109+ { 'value': 'flutter', 'title ': 'Flutter' },
110+ { 'value': 'react', 'title ': 'React Native' },
103111];
104112
105113@override
106114Widget build(BuildContext context) {
107- return SmartSelect.sheet (
115+ return SmartSelect(
108116 title: 'Frameworks',
109117 value: value,
110- option: SmartSelectOption(options),
118+ option: SmartSelectOptionConfig(options),
119+ modal: SmartSelectModalConfig(
120+ type: SmartSelectModalType.bottomSheet,
121+ ),
111122 onChange: (val) => setState(() => value = val),
112123 );
113124}
@@ -118,17 +129,20 @@ Widget build(BuildContext context) {
118129```
119130String value = 'flutter';
120131List options = [
121- { 'value': 'ionic', 'label ': 'Ionic' },
122- { 'value': 'flutter', 'label ': 'Flutter' },
123- { 'value': 'react', 'label ': 'React Native' },
132+ { 'value': 'ionic', 'title ': 'Ionic' },
133+ { 'value': 'flutter', 'title ': 'Flutter' },
134+ { 'value': 'react', 'title ': 'React Native' },
124135];
125136
126137@override
127138Widget build(BuildContext context) {
128- return SmartSelect.popup (
139+ return SmartSelect(
129140 title: 'Frameworks',
130141 value: value,
131- option: SmartSelectOption(options),
142+ option: SmartSelectOptionConfig(options),
143+ modal: SmartSelectModalConfig(
144+ type: SmartSelectModalType.popupDialog,
145+ ),
132146 onChange: (val) => setState(() => value = val),
133147 );
134148}
@@ -146,11 +160,11 @@ List options = [
146160
147161@override
148162Widget build(BuildContext context) {
149- return SmartSelect.popup (
163+ return SmartSelect(
150164 title: 'Frameworks',
151165 value: value,
152- option: SmartSelectOption (options),
153- builder: (context, state) {
166+ option: SmartSelectOptionConfig (options),
167+ builder: (context, state, showChoices ) {
154168 return ListTile(
155169 title: Text(state.title),
156170 subtitle: Text(
@@ -167,7 +181,7 @@ Widget build(BuildContext context) {
167181 ),
168182 ),
169183 trailing: Icon(Icons.keyboard_arrow_right, color: Colors.grey),
170- onTap: () => state.showOptions (context),
184+ onTap: () => showChoices (context),
171185 );
172186 },
173187 onChange: (val) => setState(() => value = val),
@@ -187,15 +201,29 @@ List options = [
187201
188202@override
189203Widget build(BuildContext context) {
190- return SmartSelect.popup(
191- title: 'Frameworks',
192- value: value,
193- option: SmartSelectOption(
194- options,
195- label: 'id',
196- value: 'text',
197- ),
198- onChange: (val) => setState(() => value = val),
204+ return Column(
205+ children: [
206+ SmartSelect(
207+ title: 'Frameworks',
208+ value: value,
209+ option: SmartSelectOption(
210+ options,
211+ value: 'id',
212+ title: 'text',
213+ ),
214+ onChange: (val) => setState(() => value = val),
215+ ),
216+ SmartSelect(
217+ title: 'Frameworks',
218+ value: value,
219+ option: SmartSelectOption(
220+ options,
221+ value: (item) => item['id'],
222+ title: (item) => item['text'],
223+ ),
224+ onChange: (val) => setState(() => value = val),
225+ )
226+ ]
199227 );
200228}
201229```
0 commit comments