update after show causes widget not mounted crash #29
Comments
Me too. |
Hi, can you post sample code which I can use to test. |
Hello @fayaz07 please see this repo for the code: |
if you would like to show the dialog, when the widget is initalised, use this code void main() => runApp(MaterialApp(home: MyApp()));
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
ProgressDialog progressDialog;
@override
Widget build(BuildContext context) {
progressDialog = ProgressDialog(context);
WidgetsBinding.instance.addPostFrameCallback((Duration d){
progressDialog.show();
});
return Scaffold(
);
}
} |
this didn't give me any issue |
Did you test it with the navigation from home class in main? |
this isn't the issue |
Hello @fayaz07, any updates? |
Still same? |
@fayaz07 unfortunately issue isn't resolved. Not always but sometimes I get the error and crash. |
Hi everyone, please use await for showing and hiding the dialog just as
|
Using update method after show method causes the following crash error:
Unhandled Exception: setState() called in constructor: (lifecycle state: created, no widget, not mounted) This happens when you call setState() on a State object for a widget that hasn't been inserted into the widget tree yet. It is not necessary to call setState() in the constructor, since the state is already assumed to be dirty when it is initially created.
To Reproduce
Steps to reproduce the behavior:
The text was updated successfully, but these errors were encountered: