maybeOf static method
The current GoRouter in the widget tree, if any.
Implementation
static GoRouter? maybeOf(BuildContext context) {
final inherited =
context
.getElementForInheritedWidgetOfExactType<InheritedGoRouter>()
?.widget
as InheritedGoRouter?;
if (inherited != null) {
return inherited.goRouter;
}
// Check if we're in a redirect context
return Zone.current[currentRouterKey] as GoRouter?;
}