maybeOf<T extends Object?> static method
- BuildContext context
Retrieves the immediate Router ancestor from the given context.
This method provides access to the delegates in the Router. For example, this can be used to access the backButtonDispatcher of the parent router when creating a ChildBackButtonDispatcher for a nested Router.
If no Router
ancestor exists for the given context, this will return
null.
See also:
Implementation
static Router<T>? maybeOf<T extends Object?>(BuildContext context) {
final _RouterScope? scope = context.dependOnInheritedWidgetOfExactType<_RouterScope>();
return scope?.routerState.widget as Router<T>?;
}