Description
Steps to reproduce
For better understanding, run the DartPad example and follow these steps:
- Use
DropdownButtonFormField
with items:['cat1', 'cat2', 'add category']
. - Select
'add category'
, which triggers a function that attempts to clear the selected value (value = null
).- At this point, the dropdown still displays
'add category'
as the selected value.
- At this point, the dropdown still displays
- Now, select another option (e.g.,
'cat1'
or'cat2'
) to set a new value. - Then select
'add category'
again. This time, the same function clears the dropdown value correctly.
✅ If you replace DropdownButtonFormField
with DropdownButton
, the dropdown clears as expected in both attempts.
Expected results
The DropdownButtonFormField
should immediately reflect the cleared state (i.e., no selected item) when its value
is set to null
, regardless of the dropdown’s previous selection.
Actual results
When value = null
is triggered after selecting 'add category'
directly, the dropdown continues to display 'add category'
as the selected item.
Only after selecting a different value first (e.g., 'cat1'
), and then selecting 'add category'
, does the DropdownButtonFormField
correctly clear the selection and reflect the null state.
This behavior is inconsistent and does not occur when using DropdownButton
, where clearing the value works immediately.
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.32.0, on macOS 15.3.2 24D81 darwin-arm64, locale en-IN) [4.6s]
• Flutter version 3.32.0 on channel stable at /Users/Library/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision be698c48a6 (2 weeks ago), 2025-05-19 12:59:14 -0700
• Engine revision 1881800949
• Dart version 3.8.0
• DevTools version 2.45.1
[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [6.6s]
• Android SDK at /Users/Library/Android/sdk
• Platform android-36, build-tools 36.0.0
• Java binary at: /Applications/Android Studio
Preview.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [6.9s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16F6
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [55ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2025.1.2) [53ms]
• Android Studio at /Applications/Android Studio Preview.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13391695-b895.109)
[✓] Android Studio (version 2024.3) [51ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
[✓] IntelliJ IDEA Community Edition (version 2024.1.6) [50ms]
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.100.2) [17ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.112.0
[✓] Connected device (3 available) [7.3s]
• iPhone 16 Plus (mobile) • 0EA0F927-2B4A-441B-8D4A-A3289AAB4ACA • ios •
com.apple.CoreSimulator.SimRuntime.iOS-18-5 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.3.2 24D81
darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome
137.0.7151.56
[✓] Network resources [467ms]
• All expected network resources are available.
• No issues found!