Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Use maybeOf instead of .of to avoid null check error if the InheritedWidget is not an ancestor

ashilkn2d88f4f6d724
diff --git a/mobile/lib/states/detail_page_state.dart b/mobile/lib/states/detail_page_state.dart
index 83df0558cb..b4770b4e38 100644
--- a/mobile/lib/states/detail_page_state.dart
+++ b/mobile/lib/states/detail_page_state.dart
@@ -11,6 +11,9 @@ class InheritedDetailPageState extends InheritedWidget {
static InheritedDetailPageState of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<InheritedDetailPageState>()!;
+ static InheritedDetailPageState? maybeOf(BuildContext context) =>
+ context.dependOnInheritedWidgetOfExactType<InheritedDetailPageState>();
+
void toggleFullScreen({bool? shouldEnable}) {
if (shouldEnable != null) {
if (enableFullScreenNotifier.value == shouldEnable) return;
diff --git a/mobile/lib/ui/viewer/file/zoomable_image.dart b/mobile/lib/ui/viewer/file/zoomable_image.dart
index f3c8073504..f9f2379369 100644
--- a/mobile/lib/ui/viewer/file/zoomable_image.dart
+++ b/mobile/lib/ui/viewer/file/zoomable_image.dart
@@ -194,8 +194,9 @@ class _ZoomableImageState extends State<ZoomableImage> {
left: 0,
right: 0,
child: ValueListenableBuilder<bool>(
- valueListenable: InheritedDetailPageState.of(context)
- .enableFullScreenNotifier,
+ valueListenable: InheritedDetailPageState.maybeOf(context)
+ ?.enableFullScreenNotifier ??
+ ValueNotifier(false),
builder: (context, doNotShowCaption, _) {
return AnimatedOpacity(
opacity: doNotShowCaption ? 0.0 : 1.0,