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