Skip to content

Commit 60ed3a9

Browse files
committed
More type safety
1 parent 6f63260 commit 60ed3a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+957
-912
lines changed

example/lib/features_choices/choices_divider.dart

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,53 @@ class FeaturesChoicesDivider extends StatefulWidget {
1010
class _FeaturesChoicesDividerState extends State<FeaturesChoicesDivider> {
1111

1212
String _car = '';
13-
List _smartphone = [];
13+
List<String> _smartphone = [];
1414

1515
@override
1616
Widget build(BuildContext context) {
1717
return Column(
1818
children: <Widget>[
1919
Container(height: 7),
20-
SmartSelect(
20+
SmartSelect<String>.single(
2121
title: 'Car',
2222
placeholder: 'Choose one',
2323
isTwoLine: true,
2424
value: _car,
25-
option: SmartSelectOptionConfig(
26-
options.cars,
27-
groupBy: 'body',
25+
options: SmartSelectOption.listFrom<Map, String>(
26+
source: options.cars,
27+
value: (index, item) => item['value'],
28+
title: (index, item) => item['title'],
29+
group: (index, item) => item['body'],
30+
),
31+
choiceConfig: SmartSelectChoiceConfig(
32+
isGrouped: true,
33+
useDivider: true
2834
),
29-
choice: SmartSelectChoiceConfig(useDivider: true),
3035
leading: CircleAvatar(
3136
backgroundImage: NetworkImage('https://source.unsplash.com/yeVtxxPxzbw/100x100'),
3237
),
3338
onChange: (val) => setState(() => _car = val),
3439
),
3540
Divider(indent: 20),
36-
SmartSelect(
41+
SmartSelect<String>.multiple(
3742
title: 'Smartphones',
3843
placeholder: 'Choose one',
3944
value: _smartphone,
4045
isTwoLine: true,
41-
isMultiChoice: true,
42-
option: SmartSelectOptionConfig(
43-
options.smartphones,
44-
value: 'id',
45-
title: 'name',
46-
groupBy: 'brand',
46+
options: SmartSelectOption.listFrom<Map, String>(
47+
source: options.smartphones,
48+
value: (index, item) => item['id'],
49+
title: (index, item) => item['name'],
50+
group: (index, item) => item['brand'],
51+
),
52+
modalType: SmartSelectModalType.bottomSheet,
53+
modalConfig: SmartSelectModalConfig(
54+
useFilter: true,
4755
),
48-
modal: SmartSelectModalConfig(
49-
type: SmartSelectModalType.bottomSheet,
50-
useFilter: true
56+
choiceConfig: SmartSelectChoiceConfig(
57+
isGrouped: true,
58+
useDivider: true,
5159
),
52-
choice: SmartSelectChoiceConfig(useDivider: true),
5360
leading: CircleAvatar(
5461
backgroundImage: NetworkImage('https://source.unsplash.com/xsGxhtAsfSA/100x100'),
5562
),

example/lib/features_choices/choices_grouped.dart

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,42 @@ class _FeaturesChoicesGroupedState extends State<FeaturesChoicesGrouped> {
1717
return Column(
1818
children: <Widget>[
1919
Container(height: 7),
20-
SmartSelect(
20+
SmartSelect.single(
2121
title: 'Smartphones',
2222
placeholder: 'Choose one',
2323
isTwoLine: true,
2424
value: _smartphone,
25-
option: SmartSelectOptionConfig(
26-
options.smartphones,
27-
value: 'id',
28-
title: 'name',
29-
groupBy: 'brand',
30-
),
31-
modal: SmartSelectModalConfig(
32-
type: SmartSelectModalType.bottomSheet,
25+
options: SmartSelectOption.listFrom<Map, String>(
26+
source: options.smartphones,
27+
value: (index, item) => item['id'],
28+
title: (index, item) => item['name'],
29+
group: (index, item) => item['brand'],
3330
),
31+
modalType: SmartSelectModalType.bottomSheet,
32+
choiceConfig: SmartSelectChoiceConfig(isGrouped: true),
3433
leading: CircleAvatar(
3534
backgroundImage: NetworkImage('https://source.unsplash.com/xsGxhtAsfSA/100x100'),
3635
),
3736
onChange: (val) => setState(() => _smartphone = val),
3837
),
3938
Divider(indent: 20),
40-
SmartSelect(
39+
SmartSelect.multiple(
4140
title: 'Cars',
4241
placeholder: 'Choose one or more',
4342
isTwoLine: true,
4443
value: _car,
45-
isMultiChoice: true,
46-
option: SmartSelectOptionConfig(
47-
options.cars,
48-
groupBy: 'body',
44+
options: SmartSelectOption.listFrom<Map, String>(
45+
source: options.cars,
46+
value: (index, item) => item['value'],
47+
title: (index, item) => item['title'],
48+
group: (index, item) => item['body'],
4949
),
50-
modal: SmartSelectModalConfig(
51-
type: SmartSelectModalType.bottomSheet,
50+
modalType: SmartSelectModalType.bottomSheet,
51+
modalConfig: SmartSelectModalConfig(
5252
useConfirmation: true,
5353
useFilter: true,
5454
),
55+
choiceConfig: SmartSelectChoiceConfig(isGrouped: true),
5556
leading: CircleAvatar(
5657
backgroundImage: NetworkImage('https://source.unsplash.com/yeVtxxPxzbw/100x100'),
5758
),

example/lib/features_choices/choices_theme.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,23 @@ class _FeaturesChoicesThemeState extends State<FeaturesChoicesTheme> {
1717
return Column(
1818
children: <Widget>[
1919
Container(height: 7),
20-
SmartSelect(
20+
SmartSelect.multiple(
2121
title: 'Smartphones',
2222
value: _smartphones,
2323
isTwoLine: true,
24-
isMultiChoice: true,
2524
leading: IconBadge(
2625
icon: const Icon(Icons.shopping_cart),
2726
counter: _smartphones.length,
2827
),
29-
option: SmartSelectOptionConfig(
30-
options.smartphones,
31-
value: 'id',
32-
title: 'name',
33-
groupBy: 'brand',
28+
options: SmartSelectOption.listFrom<Map, String>(
29+
source: options.smartphones,
30+
value: (index, item) => item['id'],
31+
title: (index, item) => item['name'],
32+
group: (index, item) => item['brand'],
3433
),
35-
modal: SmartSelectModalConfig(
34+
modalType: SmartSelectModalType.fullPage,
35+
modalConfig: SmartSelectModalConfig(
3636
useFilter: true,
37-
type: SmartSelectModalType.fullPage,
3837
style: SmartSelectModalStyle(
3938
backgroundColor: Colors.blueGrey[800],
4039
),
@@ -47,9 +46,10 @@ class _FeaturesChoicesThemeState extends State<FeaturesChoicesTheme> {
4746
actionsIconTheme: IconThemeData(color: Colors.white),
4847
),
4948
),
50-
choice: SmartSelectChoiceConfig(
49+
choiceType: SmartSelectChoiceType.switches,
50+
choiceConfig: SmartSelectChoiceConfig(
51+
isGrouped: true,
5152
useDivider: true,
52-
type: SmartSelectChoiceType.switches,
5353
glowingOverscrollIndicatorColor: Colors.green,
5454
style: SmartSelectChoiceStyle(
5555
titleStyle: TextStyle(

example/lib/features_modal/modal_confirm.dart

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@ class _FeaturesModalConfirmState extends State<FeaturesModalConfirm> {
1818
return Column(
1919
children: <Widget>[
2020
Container(height: 7),
21-
SmartSelect(
21+
SmartSelect.multiple(
2222
title: 'Days',
2323
value: _day,
2424
isTwoLine: true,
25-
isMultiChoice: true,
26-
option: SmartSelectOptionConfig(
27-
options.days,
28-
),
29-
modal: SmartSelectModalConfig(
30-
type: SmartSelectModalType.fullPage,
25+
options: options.days,
26+
modalType: SmartSelectModalType.fullPage,
27+
modalConfig: SmartSelectModalConfig(
3128
useConfirmation: true,
3229
),
3330
leading: CircleAvatar(
@@ -36,16 +33,13 @@ class _FeaturesModalConfirmState extends State<FeaturesModalConfirm> {
3633
onChange: (val) => setState(() => _day = val)
3734
),
3835
Divider(indent: 20),
39-
SmartSelect(
36+
SmartSelect.multiple(
4037
title: 'Fruit',
4138
value: _fruit,
4239
isTwoLine: true,
43-
isMultiChoice: true,
44-
option: SmartSelectOptionConfig(
45-
options.fruits,
46-
),
47-
modal: SmartSelectModalConfig(
48-
type: SmartSelectModalType.popupDialog,
40+
options: options.fruits,
41+
modalType: SmartSelectModalType.popupDialog,
42+
modalConfig: SmartSelectModalConfig(
4943
useConfirmation: true,
5044
),
5145
leading: Container(
@@ -56,14 +50,14 @@ class _FeaturesModalConfirmState extends State<FeaturesModalConfirm> {
5650
onChange: (val) => setState(() => _fruit = val),
5751
),
5852
Divider(indent: 20),
59-
SmartSelect(
53+
SmartSelect.single(
6054
title: 'Super Hero',
6155
value: _hero,
6256
isTwoLine: true,
63-
option: SmartSelectOptionConfig(options.heroes),
64-
modal: SmartSelectModalConfig(
57+
options: options.heroes,
58+
modalType: SmartSelectModalType.bottomSheet,
59+
modalConfig: SmartSelectModalConfig(
6560
useConfirmation: true,
66-
type: SmartSelectModalType.bottomSheet
6761
),
6862
leading: CircleAvatar(
6963
backgroundImage: NetworkImage('https://source.unsplash.com/8I-ht65iRww/100x100'),

example/lib/features_modal/modal_filter.dart

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,39 @@ class _FeaturesModalFilterState extends State<FeaturesModalFilter> {
1717
return Column(
1818
children: <Widget>[
1919
Container(height: 7),
20-
SmartSelect(
20+
SmartSelect.single(
2121
title: 'Car',
2222
placeholder: 'Choose one',
2323
value: _car,
2424
isTwoLine: true,
25-
option: SmartSelectOptionConfig(
26-
options.cars,
27-
groupBy: 'brand',
28-
),
29-
modal: SmartSelectModalConfig(
30-
useFilter: true,
25+
options: SmartSelectOption.listFrom<Map, String>(
26+
source: options.cars,
27+
value: (index, item) => item['value'],
28+
title: (index, item) => item['title'],
29+
group: (index, item) => item['brand'],
3130
),
31+
choiceConfig: SmartSelectChoiceConfig(isGrouped: true),
32+
modalConfig: SmartSelectModalConfig(useFilter: true),
3233
leading: CircleAvatar(
3334
backgroundImage: NetworkImage('https://source.unsplash.com/yeVtxxPxzbw/100x100'),
3435
),
3536
onChange: (val) => setState(() => _car = val),
3637
),
3738
Divider(indent: 20),
38-
SmartSelect(
39+
SmartSelect.multiple(
3940
title: 'Smartphones',
4041
placeholder: 'Choose one',
4142
value: _smartphone,
4243
isTwoLine: true,
43-
isMultiChoice: true,
44-
option: SmartSelectOptionConfig(
45-
options.smartphones,
46-
value: 'id',
47-
title: 'name',
48-
groupBy: 'category',
44+
options: SmartSelectOption.listFrom<Map, String>(
45+
source: options.smartphones,
46+
value: (index, item) => item['id'],
47+
title: (index, item) => item['name'],
48+
group: (index, item) => item['category'],
4949
),
50-
modal: SmartSelectModalConfig(
51-
type: SmartSelectModalType.bottomSheet,
50+
choiceConfig: SmartSelectChoiceConfig(isGrouped: true),
51+
modalType: SmartSelectModalType.bottomSheet,
52+
modalConfig: SmartSelectModalConfig(
5253
useFilter: true,
5354
),
5455
leading: CircleAvatar(

example/lib/features_modal/modal_header.dart

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ class _FeaturesModalHeaderState extends State<FeaturesModalHeader> {
1919
return Column(
2020
children: <Widget>[
2121
Container(height: 7),
22-
SmartSelect(
22+
SmartSelect.multiple(
2323
title: 'Month',
2424
value: _month,
2525
isTwoLine: true,
26-
isMultiChoice: true,
2726
leading: IconBadge(
2827
icon: const Icon(Icons.calendar_today),
2928
counter: _month.length,
3029
),
31-
option: SmartSelectOptionConfig(options.months),
32-
modal: SmartSelectModalConfig(
30+
options: options.months,
31+
modalConfig: SmartSelectModalConfig(
3332
useFilter: true,
3433
headerStyle: SmartSelectModalHeaderStyle(
3534
elevation: 4,
@@ -43,12 +42,12 @@ class _FeaturesModalHeaderState extends State<FeaturesModalHeader> {
4342
onChange: (val) => setState(() => _month = val)
4443
),
4544
Divider(indent: 20),
46-
SmartSelect(
45+
SmartSelect.single(
4746
title: 'Frameworks',
4847
value: _framework,
49-
option: SmartSelectOptionConfig(options.frameworks),
50-
modal: SmartSelectModalConfig(
51-
type: SmartSelectModalType.popupDialog,
48+
options: options.frameworks,
49+
modalType: SmartSelectModalType.popupDialog,
50+
modalConfig: SmartSelectModalConfig(
5251
headerStyle: SmartSelectModalHeaderStyle(
5352
backgroundColor: Colors.blueGrey[50],
5453
centerTitle: true,
@@ -65,15 +64,14 @@ class _FeaturesModalHeaderState extends State<FeaturesModalHeader> {
6564
onChange: (val) => setState(() => _framework = val),
6665
),
6766
Divider(indent: 20),
68-
SmartSelect(
67+
SmartSelect.multiple(
6968
title: 'Super Hero',
7069
value: _hero,
7170
isTwoLine: true,
72-
isMultiChoice: true,
73-
option: SmartSelectOptionConfig(options.heroes),
74-
modal: SmartSelectModalConfig(
71+
options: options.heroes,
72+
modalType: SmartSelectModalType.bottomSheet,
73+
modalConfig: SmartSelectModalConfig(
7574
useFilter: true,
76-
type: SmartSelectModalType.bottomSheet,
7775
headerStyle: SmartSelectModalHeaderStyle(
7876
centerTitle: true,
7977
),

example/lib/features_modal/modal_headerless.dart

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ class _FeaturesModalHeaderlessState extends State<FeaturesModalHeaderless> {
1717
return Column(
1818
children: <Widget>[
1919
Container(height: 7),
20-
SmartSelect(
20+
SmartSelect.multiple(
2121
title: 'Fruit',
2222
value: _fruit,
2323
isTwoLine: true,
24-
isMultiChoice: true,
25-
option: SmartSelectOptionConfig(
26-
options.fruits,
27-
),
28-
modal: SmartSelectModalConfig(
29-
type: SmartSelectModalType.popupDialog,
24+
options: options.fruits,
25+
modalType: SmartSelectModalType.popupDialog,
26+
modalConfig: SmartSelectModalConfig(
3027
useHeader: false,
3128
),
3229
leading: Container(
@@ -37,16 +34,13 @@ class _FeaturesModalHeaderlessState extends State<FeaturesModalHeaderless> {
3734
onChange: (val) => setState(() => _fruit = val),
3835
),
3936
Divider(indent: 20),
40-
SmartSelect(
37+
SmartSelect.multiple(
4138
title: 'Super Hero',
4239
value: _hero,
4340
isTwoLine: true,
44-
isMultiChoice: true,
45-
option: SmartSelectOptionConfig(
46-
options.heroes,
47-
),
48-
modal: SmartSelectModalConfig(
49-
type: SmartSelectModalType.bottomSheet,
41+
options: options.heroes,
42+
modalType: SmartSelectModalType.bottomSheet,
43+
modalConfig: SmartSelectModalConfig(
5044
useHeader: false,
5145
),
5246
leading: CircleAvatar(

example/lib/features_modal/modal_leading.dart

Whitespace-only changes.

0 commit comments

Comments
 (0)