navigatorKey property

GlobalKey<NavigatorState> navigatorKey

A key to use when building the Navigator.

If a navigatorKey is specified, the Navigator can be directly manipulated without first obtaining it from a BuildContext via Navigator.of: from the navigatorKey, use the GlobalKey.currentState getter.

If this is changed, a new Navigator will be created, losing all the application state in the process; in that case, the navigatorObservers must also be changed, since the previous observers will be attached to the previous navigator.

The Navigator is only built if routes are provided (either via home, routes, onGenerateRoute, or onUnknownRoute); if they are not, navigatorKey must be null and builder must not be null.


final GlobalKey<NavigatorState> navigatorKey