2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Bug fix for refreshable state

- Prevent setstate if widget is no longer mounted
This commit is contained in:
Oliver Walters 2022-07-20 17:38:32 +10:00
parent 19ad3153e4
commit 0165a4bad5

View File

@ -88,8 +88,10 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
return;
}
// Refresh the widget - handler for custom request() method
Future<void> refresh(BuildContext context) async {
// Escape if the widget is no longer loaded
if (!mounted) {
return;
}
@ -100,6 +102,11 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
await request(context);
// Escape if the widget is no longer loaded
if (!mounted) {
return;
}
setState(() {
loading = false;
});