The state from the closest instance of this class that encloses the given context.
Typical usage is as follows:
Navigator.of(context)
..pop()
..pop()
..pushNamed('/settings');
Source
static NavigatorState of(BuildContext context) { NavigatorState navigator = context.ancestorStateOfType(const TypeMatcher<NavigatorState>()); assert(() { if (navigator == null) { throw new FlutterError( 'Navigator operation requested with a context that does not include a Navigator.\n' 'The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.' ); } return true; }); return navigator; }