maybeOf static method

GoRouter? maybeOf(
  1. BuildContext context
)

The current GoRouter in the widget tree, if any.

This method returns null when it is called during redirects.

Implementation

static GoRouter? maybeOf(BuildContext context) {
  final InheritedGoRouter? inherited = context
      .getElementForInheritedWidgetOfExactType<InheritedGoRouter>()
      ?.widget as InheritedGoRouter?;
  return inherited?.goRouter;
}