From 90b79a65e0ea79c086bb11e6454bf3bf72228bd8 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Sun, 29 Aug 2021 19:57:10 +0800 Subject: [PATCH] Fix misusing context after widget disposed --- lib/widget/viewer_detail_pane.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/widget/viewer_detail_pane.dart b/lib/widget/viewer_detail_pane.dart index aee9b6b9..b9a7cca7 100644 --- a/lib/widget/viewer_detail_pane.dart +++ b/lib/widget/viewer_detail_pane.dart @@ -388,7 +388,9 @@ class _ViewerDetailPaneState extends State { try { await UpdateProperty(fileRepo) .updateIsArchived(widget.account, widget.file, true); - Navigator.of(context).pop(); + if (mounted) { + Navigator.of(context).pop(); + } } catch (e, stackTrace) { _log.shout( "[_onArchivePressed] Failed while archiving file" + @@ -412,7 +414,9 @@ class _ViewerDetailPaneState extends State { try { await UpdateProperty(fileRepo) .updateIsArchived(widget.account, widget.file, false); - Navigator.of(context).pop(); + if (mounted) { + Navigator.of(context).pop(); + } } catch (e, stackTrace) { _log.shout( "[_onUnarchivePressed] Failed while archiving file" + @@ -448,9 +452,11 @@ class _ViewerDetailPaneState extends State { try { await UpdateProperty(fileRepo) .updateOverrideDateTime(widget.account, widget.file, value); - setState(() { - _dateTime = value; - }); + if (mounted) { + setState(() { + _dateTime = value; + }); + } } catch (e, stacktrace) { _log.shout( "[_onDateTimeTap] Failed while updateOverrideDateTime" +