Fix accessing context during initState

This commit is contained in:
Ming Ming 2021-07-03 19:32:23 +08:00
parent 296aa9a99f
commit 7030376137
4 changed files with 20 additions and 4 deletions

View file

@ -66,7 +66,11 @@ class _AlbumPickerDialogState extends State<AlbumPickerDialog> {
_reqQuery();
} else {
// process the current state
_onStateChange(context, _bloc.state);
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_onStateChange(context, _bloc.state);
});
});
}
}

View file

@ -83,7 +83,11 @@ class _ArchiveViewerState extends State<ArchiveViewer>
_reqQuery();
} else {
// process the current state
_onStateChange(context, _bloc.state);
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_onStateChange(context, _bloc.state);
});
});
}
}

View file

@ -82,7 +82,11 @@ class _HomeAlbumsState extends State<HomeAlbums> {
_reqQuery();
} else {
// process the current state
_onStateChange(context, _bloc.state);
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_onStateChange(context, _bloc.state);
});
});
}
}

View file

@ -83,7 +83,11 @@ class _HomePhotosState extends State<HomePhotos>
_reqQuery();
} else {
// process the current state
_onStateChange(context, _bloc.state);
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_onStateChange(context, _bloc.state);
});
});
}
}