-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.3, on macOS 14.2.1 23C71 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.2)
[✓] Connected device (3 available)
[✓] Network resources
We have a DropdownButtonFormField which we have disabled by setting the onChanged to null. This works fine as the look and feel of the widget show a disabled state and the user cannot change the value. I just figured out that we can also set the items to null and use the disabledHint property so I am not sure if setting onChanged to null is a "valid" way of disabling a DropdownButtonFormField.
Once the user is done submitting the form we reset it using a GlobalKey
final _formKey = GlobalKey(debugLabel: '_ClientEditState');
and call the reset() function on the formState like so:
_formKey.currentState?.reset()
This triggers a reset() on all form fields but on a DropdownButtonFormField without a onChanged it creates a NPE.
This is because of the following line of code in the dropdown reset() function:
_dropdownButtonFormField.onChanged!(value);
As onChanged can be null (and it seems also that this can be intended behaviour to disable the widget because the widget becomes disabled) there should be a null check around this call.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status