Flutter – ‘initialValue == null || controller == null’: is not true. error

Posted by

Error:


The relevant error-causing widget was:
    PaypalPaymentPage PaypalPaymentPage:file:///C:/Users/dharm/AndroidStudioProjects/mhn_app_doctor/lib/pages/doctor_profile_page.dart:495:33

When the exception was thrown, this was the stack:
#2      new TextFormField (package:flutter/src/material/text_form_field.dart:176:15)
text_form_field.dart:176
#3      _PaypalPaymentPageState.build (package:my_hospital_now_doctor/pages/paypal_payment.dart:157:19)

Solution:

To fix this, follow these steps:

  • Remove initialValue when you’re using a controller.
  • If you’re using controller, only rely on that and don’t set initialValue.
  • If you want to display the value without editing it, use initialValue and remove the controller.

Here’s the corrected code:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x