-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Fix DropdownMenu
throwing TextEditingController
disposed error on select
#139385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7976ac7
to
34d7114
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of the problem here was that the text editing controller that was passed in was being captured by the closure, rather than being accessed new each time, so it would capture an instance that was no longer current. There's no need to pass it in, since it's a member of the state class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code wasn't handling the case where the widget got a new controller later on. It would just ignore any controller that was set later, and continue using the one it originally constructed.
b675af2
to
a03462c
Compare
DropdownMenu
throwing TextEditingController
disposed error on select
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the fix!
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
…error on select (flutter/flutter#139385)
Description
When a DropdownMenu exists within another menu and a MenuItem is selected, the
TextEditingController
of the DropdownMenu is used after it has been disposed.This PR manages the local
TextController
instance better, making sure that the one used when building is the current one, and handling the case where thecontroller
is set on the widget after initial creation.Also, places where we were setting the text and selection separately were converted to use
TextEditingValue
and set the value atomically.Related Issues
Tests