Navigator constructor Null safety

const Navigator(
  1. {Key? key,
  2. List<Page> pages = const <Page<dynamic>>[],
  3. PopPageCallback? onPopPage,
  4. String? initialRoute,
  5. RouteListFactory onGenerateInitialRoutes = Navigator.defaultGenerateInitialRoutes,
  6. RouteFactory? onGenerateRoute,
  7. RouteFactory? onUnknownRoute,
  8. TransitionDelegate transitionDelegate = const DefaultTransitionDelegate<dynamic>(),
  9. bool reportsRouteUpdateToEngine = false,
  10. List<NavigatorObserver> observers = const <NavigatorObserver>[],
  11. bool requestFocus = true,
  12. String? restorationScopeId}
)

Creates a widget that maintains a stack-based history of child widgets.

The onGenerateRoute, pages, onGenerateInitialRoutes, transitionDelegate, observers arguments must not be null.

If the pages is not empty, the onPopPage must not be null.

Implementation

const Navigator({
  super.key,
  this.pages = const <Page<dynamic>>[],
  this.onPopPage,
  this.initialRoute,
  this.onGenerateInitialRoutes = Navigator.defaultGenerateInitialRoutes,
  this.onGenerateRoute,
  this.onUnknownRoute,
  this.transitionDelegate = const DefaultTransitionDelegate<dynamic>(),
  this.reportsRouteUpdateToEngine = false,
  this.observers = const <NavigatorObserver>[],
  this.requestFocus = true,
  this.restorationScopeId,
}) : assert(pages != null),
     assert(onGenerateInitialRoutes != null),
     assert(transitionDelegate != null),
     assert(observers != null),
     assert(reportsRouteUpdateToEngine != null);