Skip to content

Commit de46b1a

Browse files
committed
Add more dartdoc comments to public API
1 parent 282fcc6 commit de46b1a

File tree

9 files changed

+95
-8
lines changed

9 files changed

+95
-8
lines changed

lib/src/choices.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ import './choices_grouped.dart';
66
import './choices_list.dart';
77
import './choices_empty.dart';
88

9+
/// modal choice widget
910
class S2Choices<T> extends StatelessWidget {
1011

12+
/// builder of single choice widget
1113
final Widget Function(S2Choice<T>) itemBuilder;
14+
15+
/// list of choice data
1216
final List<S2Choice<T>> items;
17+
18+
/// configuration of choice widget
1319
final S2ChoiceConfig config;
20+
21+
/// collection of available builder widget
1422
final S2Builder<T> builder;
23+
24+
/// current filter query
1525
final String query;
1626

27+
/// default constructor
1728
S2Choices({
1829
Key key,
1930
@required this.itemBuilder,
@@ -54,14 +65,14 @@ class S2Choices<T> extends StatelessWidget {
5465
: _nonHiddenItems;
5566
}
5667

57-
// return a non hidden option item
68+
/// return a non hidden option item
5869
List<S2Choice<T>> get _nonHiddenItems {
5970
return items
6071
.where((S2Choice<T> item) => item.hidden != true)
6172
.toList().cast<S2Choice<T>>();
6273
}
6374

64-
// return a sorted list of group keys
75+
/// return a sorted list of group keys
6576
List<String> get _groupKeys {
6677
Set groups = Set();
6778
_filteredItems.forEach((S2Choice<T> item) => groups.add(item.group));
@@ -72,6 +83,7 @@ class S2Choices<T> extends StatelessWidget {
7283
..sort((a, b) => a.toLowerCase().compareTo(b.toLowerCase()));
7384
}
7485

86+
/// whether the list need to be grouped or not
7587
bool get _isGrouped {
7688
return config.isGrouped && _groupKeys != null && _groupKeys.isNotEmpty;
7789
}

lib/src/choices_empty.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import 'package:flutter/widgets.dart';
22

3+
/// Default widget for empty choices list
34
class S2ChoicesEmpty extends StatelessWidget {
45

6+
/// default constructor
57
const S2ChoicesEmpty();
68

79
@override

lib/src/choices_grouped.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@ import 'choices_list.dart';
77
import 'scrollbar.dart';
88
import 'text.dart';
99

10+
/// grouped choices list widget
1011
class S2ChoicesGrouped<T> extends StatelessWidget {
1112

13+
/// list of string of group name
1214
final List<String> groupKeys;
15+
16+
/// item builder of choice widget
1317
final Widget Function(S2Choice<T>) itemBuilder;
18+
19+
/// list of item of choice data
1420
final List<S2Choice<T>> items;
21+
22+
/// choices configuration
1523
final S2ChoiceConfig config;
24+
25+
/// collection of builder widget
1626
final S2Builder<T> builder;
27+
28+
/// current filter query
1729
final String query;
1830

31+
/// default constructor
1932
S2ChoicesGrouped({
2033
Key key,
2134
@required this.groupKeys,
@@ -45,7 +58,7 @@ class S2ChoicesGrouped<T> extends StatelessWidget {
4558
style: config.headerStyle,
4659
);
4760
final Widget groupHeader = builder.choiceHeader?.call(context, group, query)
48-
?? SmartSelectChoicesGroupedHeader(
61+
?? S2ChoicesGroupedHeader(
4962
group: group,
5063
query: query,
5164
);
@@ -76,12 +89,17 @@ class S2ChoicesGrouped<T> extends StatelessWidget {
7689
}
7790
}
7891

79-
class SmartSelectChoicesGroupedHeader extends StatelessWidget {
92+
/// choice group header widget
93+
class S2ChoicesGroupedHeader extends StatelessWidget {
8094

95+
/// choices group data
8196
final S2ChoiceGroup group;
97+
98+
/// current filter query
8299
final String query;
83100

84-
SmartSelectChoicesGroupedHeader({
101+
/// default constructor
102+
S2ChoicesGroupedHeader({
85103
Key key,
86104
this.group,
87105
this.query,

lib/src/choices_list.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ import 'model/choice_theme.dart';
55
import 'model/choice_item.dart';
66
import 'scrollbar.dart';
77

8+
/// choices list widget
89
class S2ChoicesList<T> extends StatelessWidget {
910

11+
/// single choice widget builder
1012
final Widget Function(S2Choice<T>) itemBuilder;
13+
14+
/// list of choice data
1115
final List<S2Choice<T>> items;
16+
17+
/// configuration of single choice widget
1218
final S2ChoiceConfig config;
19+
20+
/// collection of available builder widget
1321
final S2Builder<T> builder;
1422

23+
/// default constructor
1524
S2ChoicesList({
1625
Key key,
1726
@required this.itemBuilder,
@@ -20,6 +29,7 @@ class S2ChoicesList<T> extends StatelessWidget {
2029
@required this.builder,
2130
}) : super(key: key);
2231

32+
/// get choice style
2333
S2ChoiceStyle get style => config.style;
2434

2535
@override
@@ -115,12 +125,19 @@ class S2ChoicesList<T> extends StatelessWidget {
115125
}
116126
}
117127

128+
/// default divider widget
118129
class S2Divider extends StatelessWidget {
119130

131+
/// divider color
120132
final Color color;
133+
134+
/// divider height
121135
final double height;
136+
137+
/// divider spacing
122138
final double spacing;
123139

140+
/// default constructor
124141
const S2Divider({
125142
Key key,
126143
this.color,

lib/src/choices_resolver.dart

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,35 @@ import 'model/choice_theme.dart';
55
import 'model/choice_item.dart';
66
import 'text.dart';
77

8+
/// resolve the choice builder based on choice type
89
class 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
}

lib/src/model/choice_group.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import './choice_theme.dart';
22

3+
/// choice group data
34
class S2ChoiceGroup {
45

56
/// Group name
@@ -11,6 +12,7 @@ class S2ChoiceGroup {
1112
/// Group style
1213
final S2ChoiceHeaderStyle style;
1314

15+
/// default constructor
1416
S2ChoiceGroup({
1517
this.name,
1618
this.count,

lib/src/state/filter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/foundation.dart';
22
import 'package:flutter/widgets.dart';
33

4+
/// state of filter data
45
class S2Filter extends ChangeNotifier {
56

67
bool _activated = false;

lib/src/text.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import 'package:flutter/widgets.dart';
22

3+
/// text widget that supports highlight
34
class S2Text extends StatelessWidget {
5+
6+
/// the text data string
47
final String text;
8+
9+
/// the text style
510
final TextStyle style;
11+
12+
/// the highlight data string
613
final String highlight;
14+
15+
/// the highlight color
716
final Color highlightColor;
17+
18+
/// whether the match is case sensitive or not
819
final bool caseSensitive;
920

21+
/// default constructor
1022
const S2Text({
1123
Key key,
1224
this.text,

lib/src/utils/debouncer.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import 'dart:async';
22

3+
/// A debounce function completely halts function calls
4+
/// until the call rate of the function falls low enough
35
class Debouncer {
6+
7+
/// debouncer delay
48
final Duration delay;
9+
10+
/// debouncer timer
511
Timer _timer;
612

13+
/// default constructor
714
Debouncer({
815
this.delay = const Duration(milliseconds: 300)
916
});
1017

18+
/// run the function
1119
run(Function action, { Duration delay }) {
1220
_timer?.cancel();
1321
_timer = Timer(delay ?? this.delay, action);

0 commit comments

Comments
 (0)