Navigator constructor Null safety

const Navigator(
  1. {Key? key,
  2. List<Page> pages,
  3. PopPageCallback? onPopPage,
  4. String? initialRoute,
  5. RouteListFactory onGenerateInitialRoutes,
  6. RouteFactory? onGenerateRoute,
  7. RouteFactory? onUnknownRoute,
  8. TransitionDelegate transitionDelegate,
  9. bool reportsRouteUpdateToEngine,
  10. List<NavigatorObserver> observers,
  11. 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({
  Key? 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.restorationScopeId,
}) : assert(pages != null),
     assert(onGenerateInitialRoutes != null),
     assert(transitionDelegate != null),
     assert(observers != null),
     assert(reportsRouteUpdateToEngine != null),
     super(key: key);