skip to Main Content

After building the app ios app using flutter and running it on a device, the flutter code gave an exception on visual studio IDE sometimes and crashed. The exception looks like –

enter image description here

Can anyone help why is this happening or provide a possible solution to this ?

2

Answers


  1. Call your code that calls setState with some delay like the following example.

    Future.delayed(Duration.zero, () async     {
       setState(() {
          myController.text = widget.valueText ?? '';
       });
    });
    
    Login or Signup to reply.
  2. The error is telling you that you are trying to rebuild the widget in the process of building the widget.

    To resolve this issue, simply call this line of code in the initState() method to ensure that it will be called once just before the first frame is displayed.

     @override
     void initState() {
       super.initState();
       myController.text = widget.valueText ?? '';
    
     }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search