-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
TextFormField Android "Failed assertion: 'initialValue == null || controller == null': is not true." Despite controller being null in debug. #18044
Comments
I wasn't able to reproduce this failure mode. I put a one-file version of the app (sans assets) here: https://gist.github.com/HansMuller/266cf806708fffef5440860c3892e1ed If you could explain what additional changes and what sequence of reloads/restarts are needed to trigger this failure, I'd appreciate it |
Thank you for looking into it. |
Sometimes, it helps to |
I just had this problem. For anyone else coming along, check if you have passed both Instead of this:
do this:
My problem arose when I used a refactoring option in Android Studio to convert from a stateless to a stateful widget |
@mart1n8891 Is this still an issue? |
still an issue there |
same problem |
+1 |
This isn't a bug. The failed assertion indicates that you must either provide a controller or an initialValue, but not both:
Both properties specify the text field's initial value. If the controller is specified it's typically a Stateful widget's There's more about this in the PR that introduced the assertion: #15484 |
Note also: if there's a test case out there where only specifying an initial value inexplicably triggers the assertion (as was originally reported), please reopen this bug.
|
I'm experiencing the same issue currently. I am primarily looking to have a user enter his/her location coordinates for a map marker. I was hoping to lazy load it but what about having the textfield filled upon a button press? |
nice one bro, it's solved for me !! |
Thanks! This worked! |
I catch this error at |
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 |
I want to try out flutter for a new project (Android mobile app primarily) but I regularly encounter the following error at building a TextFormField during debug on my device (Samsung Galaxy S7 G930F, Android 7.0):
The project template that I have used for trying this out is https://github.com/putraxor/flutter-login-ui
When debugging the affected sections (i.e., assert statements) -
assert(initialValue == null || controller == null);
the debugger says initialValue is a valid string, as defined, and the controller is null (which I have explicitly set tonull
before and asserted that before building the TextFormField). This issue occurs primarily during debug and results in a red screen on the device. It does not always appear in debug mode, after some manual restarts (without refreshing the code), it works sometimes beyond this point, sometimes not. This issue does not appear when running the app in regular (non-debug) mode. This issue does also not appear when using an Android emulator (e.g. Android P x86 image).The text was updated successfully, but these errors were encountered: