@@ -620,6 +620,61 @@ void main() {
620620 expect (formKey.currentState? .errors, equals ({}));
621621 });
622622 });
623+
624+ group ('multiple fields interaction -' , () {
625+ testWidgets ('Should update form builder fields when has similar fields' , (
626+ tester,
627+ ) async {
628+ // Arrange
629+ const firstDropdownName = '1_dropdown' ;
630+ const secondDropdownName = '2_dropdown' ;
631+ final firstDropdown = FormBuilderDropdown <int >(
632+ name: firstDropdownName,
633+ items: const [
634+ DropdownMenuItem (value: 1 , child: Text ('1' )),
635+ DropdownMenuItem (value: 2 , child: Text ('2' )),
636+ DropdownMenuItem (value: 3 , child: Text ('3' )),
637+ ],
638+ );
639+ final secondDropdown = FormBuilderDropdown (
640+ name: secondDropdownName,
641+ items: const [
642+ DropdownMenuItem (value: 1 , child: Text ('1' )),
643+ DropdownMenuItem (value: 2 , child: Text ('2' )),
644+ DropdownMenuItem (value: 3 , child: Text ('3' )),
645+ ],
646+ );
647+ await tester.pumpWidget (
648+ buildTestableFieldWidget (
649+ Column (children: [firstDropdown, secondDropdown]),
650+ ),
651+ );
652+
653+ // Act
654+ final firstDropdownFinder = find.byWidget (firstDropdown);
655+ await tester.tap (firstDropdownFinder);
656+ await tester.pumpAndSettle ();
657+ await tester.tap (find.text ('1' ).last);
658+ await tester.pumpAndSettle ();
659+
660+ // Assert
661+ expect (formInstantValue (firstDropdownName), 1 );
662+ expect (formInstantValue (secondDropdownName), isNull);
663+
664+ // Act
665+ final secondDropdownFinder = find.byWidget (secondDropdown);
666+ await tester.tap (secondDropdownFinder);
667+ await tester.pumpAndSettle ();
668+ await tester.tap (find.text ('2' ).last);
669+ await tester.pumpAndSettle ();
670+
671+ // Assert
672+ expect (formInstantValue (firstDropdownName), 1 );
673+ expect (formInstantValue (secondDropdownName), 2 );
674+ expect (formKey.currentState? .fields, contains (firstDropdownName));
675+ expect (formKey.currentState? .fields, contains (secondDropdownName));
676+ });
677+ });
623678}
624679
625680// simple stateful widget that can hide and show its child with the intent of
0 commit comments