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<dynamic> route = ModalRoute.of(context);
Source
static ModalRoute<dynamic> of(BuildContext context) {
_ModalScopeStatus widget = context.inheritFromWidgetOfExactType(_ModalScopeStatus);
return widget?.route;
}