mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Check if widget is mounted before calling setstate() (#193)
This commit is contained in:
parent
b7a37e50c5
commit
c5162c1947
@ -626,9 +626,9 @@ class _QRViewState extends State<InvenTreeQRView> {
|
||||
flash_status = status != null && status;
|
||||
|
||||
// Reload
|
||||
setState(() {
|
||||
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
// In order to get hot reload to work we need to pause the camera if the platform
|
||||
|
@ -46,8 +46,9 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
reportErrors = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool;
|
||||
strictHttps = await InvenTreeSettingsManager().getValue(INV_STRICT_HTTPS, false) as bool;
|
||||
|
||||
setState(() {
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -177,7 +177,9 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
|
||||
// Attempt server connection
|
||||
InvenTreeAPI().connectToServer().then((result) {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -128,8 +128,10 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _newLocation(BuildContext context) async {
|
||||
|
||||
|
@ -91,9 +91,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
Future<void> onBuild(BuildContext context) async {
|
||||
refresh(context);
|
||||
|
||||
setState(() {
|
||||
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@ -123,8 +123,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
|
||||
// Request part test templates
|
||||
part.getTestTemplates().then((value) {
|
||||
setState(() {
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
});
|
||||
|
||||
// Request the number of attachments
|
||||
@ -133,9 +134,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
"part": part.pk.toString(),
|
||||
}
|
||||
).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Request the number of BOM items
|
||||
@ -144,9 +147,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
"in_bom_for": part.pk.toString(),
|
||||
}
|
||||
).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
bomCount = value;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Request the number of variant items
|
||||
@ -155,9 +160,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
"variant_of": part.pk.toString(),
|
||||
}
|
||||
).then((int value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
variantCount = value;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -124,9 +124,12 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
|
||||
// Request test results (async)
|
||||
item.getTestResults().then((value) {
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
// Update
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Request the number of attachments
|
||||
@ -135,9 +138,12 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
"stock_item": item.pk.toString()
|
||||
}
|
||||
).then((int value) {
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Request information on labels available for this stock item
|
||||
@ -169,8 +175,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
setState(() {
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user