From 702fac4b38700e12e42ab0fd21891dab0d29d090 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Fri, 8 Dec 2023 00:08:16 +0800 Subject: [PATCH] Fix NPE in viewer pane --- app/lib/widget/viewer_detail_pane.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/lib/widget/viewer_detail_pane.dart b/app/lib/widget/viewer_detail_pane.dart index 3679410d..431ef1d2 100644 --- a/app/lib/widget/viewer_detail_pane.dart +++ b/app/lib/widget/viewer_detail_pane.dart @@ -146,11 +146,16 @@ class _ViewerDetailPaneState extends State { final timeStr = DateFormat(DateFormat.HOUR_MINUTE, Localizations.localeOf(context).languageCode) .format(_dateTime); - final collectionAdapter = CollectionAdapter.of(KiwiContainer().resolve(), - widget.account, widget.fromCollection!.collection); - final isShowDelete = widget.fromCollection != null && - collectionAdapter.isPermitted(CollectionCapability.deleteItem) && - collectionAdapter.isItemDeletable(widget.fromCollection!.item); + final bool isShowDelete; + if (widget.fromCollection != null) { + final collectionAdapter = CollectionAdapter.of(KiwiContainer().resolve(), + widget.account, widget.fromCollection!.collection); + isShowDelete = + collectionAdapter.isPermitted(CollectionCapability.deleteItem) && + collectionAdapter.isItemDeletable(widget.fromCollection!.item); + } else { + isShowDelete = false; + } return Material( type: MaterialType.transparency,