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

This commit is contained in:
ashilkn
2024-06-15 12:23:45 +05:30
parent 1b993a617a
commit f001812a1d

View File

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