Skip to content

Why is DropdownButtonFormField's onChanged required? #57953

Closed
flutter/packages
#12610

Description

@fgblomqvist

Steps to Reproduce

Try to initialize a DropdownButtonFormField without specifying the onChanged parameter.

Expected results:

For onChanged to not be required and the widget to still work, which is consistent with other FormField widgets, such as TextFormField.

Actual results:

Currently the onChanged parameter is required and is seemingly used as a way to disable the widget if you set it to null. If you don't care about the onChanged event and just want to use the DropdownButtonFormField in a normal basic form, you still have to set onChanged to an empty function (e.g. onChanged: (value) {}) otherwise it won't update the FormState/stay enabled. This feels unintuitive to me since e.g. the TextFormField widget does not require you to specify onChanged unless you're interested in that event.

While I'm not that experienced with Flutter, it seems like it would make more sense to not use onChanged as a way of disabling a DropdownButtonFormField and instead let it purely be a way of letting the user do something when the field changes. I don't know if there are issues with that or if this odd current behavior is just a leftover from old logic? Seems easy enough to change it up (I could attempt to submit a PR for it).

Proposed Changes:
Add a bool enabled parameter to DropdownButtonFormField (consistent with TextFormField) and use that to decide whether to set the underlying DropdownButton.onChanged to control its enabled'ness.

In the future, it might make sense to add an enabled parameter to DropdownButton as well, as an explicit way of controlling whether it should be enabled or not.

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    on May 26, 2020
  2. flutter-triage-bot commented on Jul 12, 2023

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-design label.

  3. added
    P3Issues that are less important to the Flutter project
    triaged-designTriaged by Design Languages team
    on Aug 3, 2023
  4. Mairramer commented on Jan 14, 2026

    @Mairramer
    Contributor

    @justinmc I’m looking into this proposal, and technically it’s straightforward. The main challenge would be refactoring some tests, which in this case means adding the enabled parameter in a few places and deciding whether it should be true or false.
    If that’s not an issue, I can start working on it.

  5. Mairramer commented on Feb 17, 2026

    @Mairramer
    Contributor

    @justinmc @Piinks I’ve prepared an implementation and submitted it as a draft. However, I’m unsure whether the impact justifies the change.

    Patterns such as onChanged: condition ? (value) { ... } : null would be affected, resulting in a small breaking change. What would be the best way to proceed?

  6. justinmc commented on Apr 28, 2026

    @justinmc
    Contributor

    @Mairramer Sorry I missed this notification here. I left a comment on the PR. I agree with your approach!

  7. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  8. github-actions commented on Oct 27, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: text inputEntering text in a text field or keyboard related problemsc: proposalA detailed proposal for a change to Flutterp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions