Fix potential use of disposed context

This commit is contained in:
Ming Ming 2022-12-03 10:02:04 +08:00
parent acc340ca7a
commit 98696b9a47

View file

@ -52,12 +52,14 @@ class _MeasurableItemListState extends State<MeasurableItemList>
@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();
}
}
});
}