navigatorKey top-level property
A GlobalKey for accessing the NavigatorState from anywhere in the app.
This key should be assigned to the navigatorKey property of your
MaterialApp or CupertinoApp.
Implementation
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();