Skip to content
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

TextEditingController dispose error #149

Closed
pulstar opened this issue Oct 4, 2019 · 3 comments
Closed

TextEditingController dispose error #149

pulstar opened this issue Oct 4, 2019 · 3 comments

Comments

@pulstar
Copy link

pulstar commented Oct 4, 2019

I am getting a weird error:

The following assertion was thrown building _FormScope:A TextEditingController was used after being disposed. Once you have called dispose() on a TextEditingController, it can no longer be used. User-created ancestor of the error-causing widget was:   FormBuilder-[LabeledGlobalKey#30305]
When the exception was thrown, this was the stack: 
#0   ChangeNotifier._debugAssertNotDisposed. (package:flutter/src/foundation/change_notifier.dart:105:9)
#1   ChangeNotifier._debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:111:6)
#2   ChangeNotifier.addListener (package:flutter/src/foundation/change_notifier.dart:141:12)
#3   FormBuilderTextFieldState.initState (package:flutter_form_builder/src/fields/form_builder_text_field.dart:111:26)
#4   StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4068:58)

I have no idea what is causing it, since I am not disposing any TextEditingController at all.

I am using version 3.5.3 of flutter_form_builder, because newer versions are incompatible with Intl 0.15.8 and newer versions of Intl are incompatible with flutter_localizations.

@danvick
Copy link
Collaborator

danvick commented Nov 3, 2019

Hi @pulstar,
Seems like your app UI is frequently rebuilding during runtime thus causing the TextEditingController used in the TextField to be disposed of.

On the issue of dependency resolution, I'd suggest having a look at this video which will help to make sure you don't remain behind just because of dependency mismatch.

@pulstar
Copy link
Author

pulstar commented Nov 4, 2019

Thank you very much! I will try.

@danvick danvick closed this as completed Dec 5, 2019
@alexrindone
Copy link

I know this is old - but I looked at my app UI a little more closely and realized I had an issue like @danvick suggested. I use the Provider package and when a user hit the bottom navigator button named "home" I popped off everything on the stack with Navigator.of(context).popUntil((route) => route.isFirst); . This caused the state to be messed up when switching to the page with my TextEditingController because it disposed of the controller when I had popped everything off the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants