[mob][photos] Handle if InheritedWidget is not an ancestor (#5399)

This commit is contained in:
Ashil
2025-03-21 13:18:23 +05:30
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@@ -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;

View File

@@ -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,