@@ -30,4 +30,45 @@ void main() {
30
30
expect (formSave (), isTrue);
31
31
expect (formValue (widgetName), equals (< num > [1 , 3 ]));
32
32
});
33
+ testWidgets ('FormBuilderCheckboxGroup -- didChange' ,
34
+ (WidgetTester tester) async {
35
+ const fieldName = 'cbg1' ;
36
+ final testWidget = FormBuilderCheckboxGroup <int >(
37
+ name: fieldName,
38
+ options: const [
39
+ FormBuilderFieldOption (key: ValueKey ('1' ), value: 1 ),
40
+ FormBuilderFieldOption (key: ValueKey ('2' ), value: 2 ),
41
+ FormBuilderFieldOption (key: ValueKey ('3' ), value: 3 ),
42
+ ],
43
+ );
44
+ await tester.pumpWidget (buildTestableFieldWidget (testWidget));
45
+
46
+ expect (formSave (), isTrue);
47
+ expect (formValue (fieldName), isNull);
48
+ formFieldDidChange (fieldName, [1 , 3 ]);
49
+ await tester.pumpAndSettle ();
50
+ expect (formSave (), isTrue);
51
+ expect (formValue (fieldName), [1 , 3 ]);
52
+
53
+ Checkbox checkbox1 = tester
54
+ .element (find.byKey (const ValueKey ('1' )))
55
+ .findAncestorWidgetOfExactType <Row >()!
56
+ .children
57
+ .first as Checkbox ;
58
+ Checkbox checkbox2 = tester
59
+ .element (find.byKey (const ValueKey ('2' )))
60
+ .findAncestorWidgetOfExactType <Row >()!
61
+ .children
62
+ .first as Checkbox ;
63
+ Checkbox checkbox3 = tester
64
+ .element (find.byKey (const ValueKey ('3' )))
65
+ .findAncestorWidgetOfExactType <Row >()!
66
+ .children
67
+ .first as Checkbox ;
68
+
69
+ // checkboxes should represent the state of the didChange value
70
+ expect (checkbox1.value, true );
71
+ expect (checkbox2.value, false );
72
+ expect (checkbox3.value, true );
73
+ });
33
74
}
0 commit comments