of<T extends Object> method

  1. @optionalTypeArgs
ModalRoute<T> of <T extends Object>(BuildContext context)
@optionalTypeArgs

Returns the modal route most closely associated with the given context.

Returns null if the given context is not associated with a modal route.

Typical usage is as follows:

ModalRoute route = ModalRoute.of(context);

The given BuildContext will be rebuilt if the state of the route changes (specifically, if isCurrent or canPop change value).

Implementation

@optionalTypeArgs
static ModalRoute<T> of<T extends Object>(BuildContext context) {
  final _ModalScopeStatus widget = context.inheritFromWidgetOfExactType(_ModalScopeStatus);
  return widget?.route;
}