@@ -29,15 +29,87 @@ void main() {
29
29
expect (formValue (widgetName), equals (const [1 , 3 ]));
30
30
});
31
31
32
- testWidgets ('FormBuilderCheckboxGroup -- decoration' ,
32
+ testWidgets ('FormBuilderCheckboxGroup -- decoration control ' ,
33
33
(WidgetTester tester) async {
34
34
const widgetName = 'cbg1' ;
35
35
final testWidget = FormBuilderCheckboxGroup <int >(
36
36
name: widgetName,
37
+ wrapSpacing: 10.0 ,
38
+ options: const [
39
+ FormBuilderFieldOption (key: ValueKey ('1' ), value: 1 ),
40
+ FormBuilderFieldOption (key: ValueKey ('2' ), value: 2 ),
41
+ ],
42
+ itemDecoration:
43
+ BoxDecoration (border: Border .all (color: Colors .blueAccent)),
44
+ );
45
+ await tester.pumpWidget (buildTestableFieldWidget (testWidget));
46
+
47
+ // this is a brittle test knowing how we use container for a border
48
+ // there is one container for each option
49
+ expect (find.byType (Container ), findsExactly (2 ));
50
+ // same as wrapSpacing
51
+ Container foo = tester.firstWidget (find.byType (Container ));
52
+ expect (foo.padding, const EdgeInsets .only (right: 10.0 ));
53
+ });
54
+
55
+ testWidgets ('FormBuilderCheckboxGroup -- decoration control following' ,
56
+ (WidgetTester tester) async {
57
+ const widgetName = 'cbg1' ;
58
+ final testWidget = FormBuilderCheckboxGroup <int >(
59
+ name: widgetName,
60
+ controlAffinity: ControlAffinity .trailing,
61
+ wrapSpacing: 10.0 ,
62
+ options: const [
63
+ FormBuilderFieldOption (key: ValueKey ('1' ), value: 1 ),
64
+ FormBuilderFieldOption (key: ValueKey ('2' ), value: 2 ),
65
+ ],
66
+ itemDecoration:
67
+ BoxDecoration (border: Border .all (color: Colors .blueAccent)),
68
+ );
69
+ await tester.pumpWidget (buildTestableFieldWidget (testWidget));
70
+
71
+ // this is a brittle test knowing how we use container for a border
72
+ // there is one container for each option
73
+ expect (find.byType (Container ), findsExactly (2 ));
74
+ // same as wrapSpacing
75
+ Container foo = tester.firstWidget (find.byType (Container ));
76
+ expect (foo.padding, const EdgeInsets .only (left: 10.0 ));
77
+ });
78
+
79
+ testWidgets ('FormBuilderCheckboxGroup -- decoration horizontal' ,
80
+ (WidgetTester tester) async {
81
+ const widgetName = 'cbg1' ;
82
+ final testWidget = FormBuilderCheckboxGroup <int >(
83
+ name: widgetName,
84
+ orientation: OptionsOrientation .horizontal,
85
+ wrapSpacing: 10.0 ,
86
+ options: const [
87
+ FormBuilderFieldOption (key: ValueKey ('1' ), value: 1 ),
88
+ FormBuilderFieldOption (key: ValueKey ('2' ), value: 2 ),
89
+ ],
90
+ itemDecoration:
91
+ BoxDecoration (border: Border .all (color: Colors .blueAccent)),
92
+ );
93
+ await tester.pumpWidget (buildTestableFieldWidget (testWidget));
94
+
95
+ // this is a brittle test knowing how we use container for a border
96
+ // there is one container for each option
97
+ expect (find.byType (Container ), findsExactly (2 ));
98
+ // same as wrapSpacing
99
+ Container foo = tester.firstWidget (find.byType (Container ));
100
+ expect (foo.margin, const EdgeInsets .only (right: 10.0 ));
101
+ });
102
+
103
+ testWidgets ('FormBuilderCheckboxGroup -- decoration vertical' ,
104
+ (WidgetTester tester) async {
105
+ const widgetName = 'cbg1' ;
106
+ final testWidget = FormBuilderCheckboxGroup <int >(
107
+ name: widgetName,
108
+ orientation: OptionsOrientation .vertical,
109
+ wrapSpacing: 10.0 ,
37
110
options: const [
38
111
FormBuilderFieldOption (key: ValueKey ('1' ), value: 1 ),
39
112
FormBuilderFieldOption (key: ValueKey ('2' ), value: 2 ),
40
- FormBuilderFieldOption (key: ValueKey ('3' ), value: 3 ),
41
113
],
42
114
itemDecoration:
43
115
BoxDecoration (border: Border .all (color: Colors .blueAccent)),
@@ -46,7 +118,10 @@ void main() {
46
118
47
119
// this is a brittle test knowing how we use container for a border
48
120
// there is one container for each option
49
- expect (find.byType (Container ), findsExactly (3 ));
121
+ expect (find.byType (Container ), findsExactly (2 ));
122
+ // same as wrapSpacing
123
+ Container foo = tester.firstWidget (find.byType (Container ));
124
+ expect (foo.margin, const EdgeInsets .only (bottom: 10.0 ));
50
125
});
51
126
52
127
testWidgets ('FormBuilderCheckboxGroup -- didChange' ,
0 commit comments