@@ -5,24 +5,35 @@ import 'model/choice_theme.dart';
55import 'model/choice_item.dart' ;
66import 'text.dart' ;
77
8+ /// resolve the choice builder based on choice type
89class S2ChoiceResolver <T > {
910
11+ /// whether single or multiple choice
1012 final bool isMultiChoice;
13+
14+ /// the choice type
1115 final S2ChoiceType type;
16+
17+ /// the choice style
1218 final S2ChoiceStyle style;
19+
20+ /// the collection of available builder widget
1321 final S2Builder <T > builder;
1422
23+ /// default constructor
1524 S2ChoiceResolver ({
1625 @required this .isMultiChoice,
1726 @required this .type,
1827 @required this .style,
1928 @required this .builder,
2029 });
2130
31+ /// get the choice builder
2232 S2ChoiceBuilder <T > get choiceBuilder {
2333 return builder.choice ?? defaultChoiceBuilder;
2434 }
2535
36+ /// get correct builder based on choice type
2637 S2ChoiceBuilder <T > get defaultChoiceBuilder {
2738 return type == S2ChoiceType .checkboxes
2839 ? checkboxBuilder
@@ -35,6 +46,7 @@ class S2ChoiceResolver<T> {
3546 : null ;
3647 }
3748
49+ /// get radio builder
3850 S2ChoiceBuilder <T > get radioBuilder => (
3951 BuildContext context,
4052 S2Choice <T > choice,
@@ -50,6 +62,7 @@ class S2ChoiceResolver<T> {
5062 value: choice.value,
5163 );
5264
65+ /// get switch builder
5366 S2ChoiceBuilder <T > get switchBuilder => (
5467 BuildContext context,
5568 S2Choice <T > choice,
@@ -68,6 +81,7 @@ class S2ChoiceResolver<T> {
6881 value: choice.selected,
6982 );
7083
84+ /// get checkbox builder
7185 S2ChoiceBuilder <T > get checkboxBuilder => (
7286 BuildContext context,
7387 S2Choice <T > choice,
@@ -84,6 +98,7 @@ class S2ChoiceResolver<T> {
8498 value: choice.selected,
8599 );
86100
101+ /// get chip builder
87102 S2ChoiceBuilder <T > get chipBuilder => (
88103 BuildContext context,
89104 S2Choice <T > choice,
@@ -138,7 +153,7 @@ class S2ChoiceResolver<T> {
138153 );
139154 };
140155
141- // build title widget
156+ /// build title widget
142157 Widget getTitle (BuildContext context, S2Choice <T > choice, String searchText) {
143158 return choice.title != null
144159 ? builder.choiceTitle != null
@@ -152,7 +167,7 @@ class S2ChoiceResolver<T> {
152167 : null ;
153168 }
154169
155- // build subtitle widget
170+ /// build subtitle widget
156171 Widget getSubtitle (BuildContext context, S2Choice <T > choice, String searchText) {
157172 return choice.subtitle != null
158173 ? builder.choiceSubtitle != null
@@ -166,7 +181,7 @@ class S2ChoiceResolver<T> {
166181 : null ;
167182 }
168183
169- // build secondary/avatar widget
184+ /// build secondary/avatar widget
170185 Widget getSecondary (BuildContext context, S2Choice <T > choice, String searchText) {
171186 return builder.choiceSecondary? .call (context, choice, searchText);
172187 }
0 commit comments