From 98696b9a47da7ae1b1c3d21115ab51c0091c01e3 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sat, 3 Dec 2022 10:02:04 +0800 Subject: [PATCH] Fix potential use of disposed context --- app/lib/widget/measurable_item_list.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/lib/widget/measurable_item_list.dart b/app/lib/widget/measurable_item_list.dart index 109bed0d..bbac1c4b 100644 --- a/app/lib/widget/measurable_item_list.dart +++ b/app/lib/widget/measurable_item_list.dart @@ -52,12 +52,14 @@ class _MeasurableItemListState extends State @override didChangeMetrics() { WidgetsBinding.instance.addPostFrameCallback((_) { - final orientation = MediaQuery.of(context).orientation; - if (orientation != _prevOrientation) { - _log.info( - "[didChangeMetrics] updateListHeight: orientation changed: $orientation"); - _prevOrientation = orientation; - updateListHeight(); + if (mounted) { + final orientation = MediaQuery.of(context).orientation; + if (orientation != _prevOrientation) { + _log.info( + "[didChangeMetrics] updateListHeight: orientation changed: $orientation"); + _prevOrientation = orientation; + updateListHeight(); + } } }); }