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;
|
flash_status = status != null && status;
|
||||||
|
|
||||||
// Reload
|
// Reload
|
||||||
setState(() {
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In order to get hot reload to work we need to pause the camera if the platform
|
// 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;
|
reportErrors = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool;
|
||||||
strictHttps = await InvenTreeSettingsManager().getValue(INV_STRICT_HTTPS, false) as bool;
|
strictHttps = await InvenTreeSettingsManager().getValue(INV_STRICT_HTTPS, false) as bool;
|
||||||
|
|
||||||
setState(() {
|
if (mounted) {
|
||||||
});
|
setState(() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -177,7 +177,9 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
|||||||
|
|
||||||
// Attempt server connection
|
// Attempt server connection
|
||||||
InvenTreeAPI().connectToServer().then((result) {
|
InvenTreeAPI().connectToServer().then((result) {
|
||||||
setState(() {});
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,9 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {});
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _newLocation(BuildContext context) async {
|
Future<void> _newLocation(BuildContext context) async {
|
||||||
|
@ -91,9 +91,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
Future<void> onBuild(BuildContext context) async {
|
Future<void> onBuild(BuildContext context) async {
|
||||||
refresh(context);
|
refresh(context);
|
||||||
|
|
||||||
setState(() {
|
if (mounted) {
|
||||||
|
setState(() {});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -123,8 +123,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
|
|
||||||
// Request part test templates
|
// Request part test templates
|
||||||
part.getTestTemplates().then((value) {
|
part.getTestTemplates().then((value) {
|
||||||
setState(() {
|
if (mounted) {
|
||||||
});
|
setState(() {});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Request the number of attachments
|
// Request the number of attachments
|
||||||
@ -133,9 +134,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
"part": part.pk.toString(),
|
"part": part.pk.toString(),
|
||||||
}
|
}
|
||||||
).then((int value) {
|
).then((int value) {
|
||||||
setState(() {
|
if (mounted) {
|
||||||
attachmentCount = value;
|
setState(() {
|
||||||
});
|
attachmentCount = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Request the number of BOM items
|
// Request the number of BOM items
|
||||||
@ -144,9 +147,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
"in_bom_for": part.pk.toString(),
|
"in_bom_for": part.pk.toString(),
|
||||||
}
|
}
|
||||||
).then((int value) {
|
).then((int value) {
|
||||||
setState(() {
|
if (mounted) {
|
||||||
bomCount = value;
|
setState(() {
|
||||||
});
|
bomCount = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Request the number of variant items
|
// Request the number of variant items
|
||||||
@ -155,9 +160,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
"variant_of": part.pk.toString(),
|
"variant_of": part.pk.toString(),
|
||||||
}
|
}
|
||||||
).then((int value) {
|
).then((int value) {
|
||||||
setState(() {
|
if (mounted) {
|
||||||
variantCount = value;
|
setState(() {
|
||||||
});
|
variantCount = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,9 +124,12 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
// Request test results (async)
|
// Request test results (async)
|
||||||
item.getTestResults().then((value) {
|
item.getTestResults().then((value) {
|
||||||
setState(() {
|
|
||||||
// Update
|
if (mounted) {
|
||||||
});
|
setState(() {
|
||||||
|
// Update
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Request the number of attachments
|
// Request the number of attachments
|
||||||
@ -135,9 +138,12 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
"stock_item": item.pk.toString()
|
"stock_item": item.pk.toString()
|
||||||
}
|
}
|
||||||
).then((int value) {
|
).then((int value) {
|
||||||
setState(() {
|
|
||||||
attachmentCount = value;
|
if (mounted) {
|
||||||
});
|
setState(() {
|
||||||
|
attachmentCount = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Request information on labels available for this stock item
|
// 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