File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed
packages/flutter_form_builder/lib Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,4 @@ export 'src/fields/form_builder_switch.dart';
18
18
export 'src/fields/form_builder_text_field.dart' ;
19
19
export 'src/widgets/grouped_checkbox.dart' ;
20
20
export 'src/widgets/grouped_radio.dart' ;
21
+ export 'src/options/form_builder_filter_chips_option.dart' ;
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ class FormBuilderFilterChip<T> extends FormBuilderField<List<T>> {
12
12
final Color ? selectedShadowColor;
13
13
final Color ? shadowColor;
14
14
final double ? elevation, pressElevation;
15
- final List <FormBuilderFieldOption <T >> options;
15
+ final List <FormBuilderFilterChipsOption <T >> options;
16
16
final MaterialTapTargetSize ? materialTapTargetSize;
17
17
final OutlinedBorder ? shape;
18
18
@@ -102,10 +102,11 @@ class FormBuilderFilterChip<T> extends FormBuilderField<List<T>> {
102
102
textDirection: textDirection,
103
103
verticalDirection: verticalDirection,
104
104
children: < Widget > [
105
- for (FormBuilderFieldOption <T > option in options)
105
+ for (FormBuilderFilterChipsOption <T > option in options)
106
106
FilterChip (
107
107
label: option,
108
108
selected: field.value! .contains (option.value),
109
+ avatar: option.avatar,
109
110
onSelected: state.enabled &&
110
111
(null == maxChips ||
111
112
field.value! .length < maxChips ||
Original file line number Diff line number Diff line change
1
+ import 'package:flutter/material.dart' ;
2
+ import 'package:flutter_form_builder/flutter_form_builder.dart' ;
3
+
4
+ /// An option for filter chips.
5
+ ///
6
+ /// The type `T` is the type of the value the entry represents. All the entries
7
+ /// in a given menu must represent values with consistent types.
8
+ class FormBuilderFilterChipsOption <T > extends FormBuilderFieldOption <T > {
9
+ final Widget ? avatar;
10
+
11
+ /// Creates an option for fields with selection options
12
+ const FormBuilderFilterChipsOption ({
13
+ Key ? key,
14
+ required value,
15
+ this .avatar,
16
+ child,
17
+ }) : super (
18
+ key: key,
19
+ value: value,
20
+ child: child,
21
+ );
22
+
23
+ @override
24
+ Widget build (BuildContext context) {
25
+ return child ?? Text (value.toString ());
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments