mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-14 12:06:24 +00:00
Bug fix for refreshable state
- Prevent setstate if widget is no longer mounted
This commit is contained in:
parent
19ad3153e4
commit
0165a4bad5
1 changed files with 7 additions and 0 deletions
|
|
@ -88,8 +88,10 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refresh the widget - handler for custom request() method
|
||||||
Future<void> refresh(BuildContext context) async {
|
Future<void> refresh(BuildContext context) async {
|
||||||
|
|
||||||
|
// Escape if the widget is no longer loaded
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -100,6 +102,11 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> with
|
||||||
|
|
||||||
await request(context);
|
await request(context);
|
||||||
|
|
||||||
|
// Escape if the widget is no longer loaded
|
||||||
|
if (!mounted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = false;
|
loading = false;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue