Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Assert that SelectionState inherited widget is in context or not

ashilknf001812a1d28
diff --git a/mobile/lib/ui/viewer/gallery/state/selection_state.dart b/mobile/lib/ui/viewer/gallery/state/selection_state.dart
index fa2fdfa171..a67ffd449f 100644
--- a/mobile/lib/ui/viewer/gallery/state/selection_state.dart
+++ b/mobile/lib/ui/viewer/gallery/state/selection_state.dart
@@ -18,10 +18,16 @@ class SelectionState extends InheritedWidget {
required Widget child,
}) : super(key: key, child: child);
- static SelectionState? of(BuildContext context) {
+ static SelectionState? maybeOf(BuildContext context) {
return context.dependOnInheritedWidgetOfExactType<SelectionState>();
}
+ static SelectionState of(BuildContext context) {
+ final SelectionState? result = maybeOf(context);
+ assert(result != null, 'No SelectionState found in context');
+ return result!;
+ }
+
@override
bool updateShouldNotify(covariant InheritedWidget oldWidget) {
return false;