of static method
Returns the NavigatorState from the closest Navigator ancestor.
Throws a StateError if no Navigator ancestor is found.
Implementation
static NavigatorState of(BuildContext context) {
final state = maybeOf(context);
if (state == null) {
throw StateError(
'Navigator.of() called with a context that does not contain '
'a Navigator.',
);
}
return state;
}