Search code examples
iosfluttervisual-studio-code

Flutter iOS App crashing sometimes unexpectedly


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 ?


Solution

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

    Future.delayed(Duration.zero, () async     {
       setState(() {
          myController.text = widget.valueText ?? '';
       });
    });