Flutterで画像をピンチイン・アウトで拡大・縮小できる大変便利な「photo_view」という有名なパッケージがありますが、
このパッケージを使っているプロジェクトで画面遷移等を行った際に、
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: master