このページには広告が含まれる場合があります。
Flutterで画像をピンチイン・アウトで拡大・縮小できる大変便利な「photo_view」という有名なパッケージがありますが、

Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interactive images and other stuff such as SVG.
このパッケージを使っているプロジェクトで画面遷移等を行った際に、
The following assertion was thrown while finalizing the widget tree: Looking up a deactivated widget's ancestor is unsafe. At this point the state of the widget's element tree is no longer stable. To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.
というエラーが出てしまう場合があります(アプリは落ちないが)。
これは、photo_viewパッケージのissueにも上がっていているのですが、現時点(2022/4)ではまだ解決されていないようなので、以下の次善の策を施してやる必要があるようです。
(pubspec.yamlファイルの「dependency_override」欄に以下を追記)
dependency_overrides:
photo_view:
git:
url: https://github.com/bluefireteam/photo_view
ref: masterOnce you navigate out of the view you see this error.. using pdfx: ^2.0.1+1. and flutter 2.10.1 it was working fine before flutter upgrade.. here is my widget code.. PhotoViewGalleryPageOptions _pa...




