flutter_form_builder icon indicating copy to clipboard operation
flutter_form_builder copied to clipboard

[FormBuilderDropdown]: silently ignores an unknown initialValue

Open grundid opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Package/Plugin version

9.2.1

Platforms

  • [X] Android
  • [X] iOS
  • [X] Linux
  • [X] MacOS
  • [X] Web
  • [X] Windows

Flutter doctor

Latest Flutter

Minimal code example

 FormBuilderDropdown(
                      name: 'weekday',
                      decoration: InputDecoration(
                        labelText: 'Weekday',
                      ),
                      initialValue: DateTime.sunday,
                      allowClear: false,
                      validator: FormBuilderValidators.compose(
                        [FormBuilderValidators.required()],
                      ),
                      items: [
                        DropdownMenuItem<int>(
                          value: DateTime.monday,
                          child: Text("Monday"),
                        )
                      ])

Current Behavior

The dropdown shows an empty entry but still keeps the value in the state. When the user saves the form the value is returned as a valid selection.

Expected Behavior

The dropdown should fail as per design if an unknown option is given.

Steps To Reproduce

see minimal code example

Aditional information

No response

grundid avatar Feb 06 '24 08:02 grundid