Router<T> constructor Null safety

const Router<T>(
  1. {Key? key,
  2. RouteInformationProvider? routeInformationProvider,
  3. RouteInformationParser<T>? routeInformationParser,
  4. required RouterDelegate<T> routerDelegate,
  5. BackButtonDispatcher? backButtonDispatcher,
  6. String? restorationScopeId}

Creates a router.

The routeInformationProvider and routeInformationParser can be null if this router does not depend on route information. A common example is a sub router that builds its content completely based on the app state.

If the routeInformationProvider or restorationScopeId is not null, then routeInformationParser must also not be null.

The routerDelegate must not be null.


const Router({
  Key? key,
  required this.routerDelegate,
})  : assert(
        (routeInformationProvider == null && restorationScopeId == null) || routeInformationParser != null,
        'A routeInformationParser must be provided when a routeInformationProvider or a restorationId is specified.'
      assert(routerDelegate != null),
      super(key: key);