Router<T>.withConfig constructor Null safety

Router<T>.withConfig(
  1. {Key? key,
  2. required RouterConfig<T> config,
  3. String? restorationScopeId}
)

Creates a router with a RouterConfig.

The RouterConfig.routeInformationProvider and RouterConfig.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 RouterConfig.routeInformationProvider is not null, then RouterConfig.routeInformationParser must also not be null.

The RouterConfig.routerDelegate must not be null.

Implementation

factory Router.withConfig({
  Key? key,
  required RouterConfig<T> config,
  String? restorationScopeId,
}) {
  return Router<T>(
    key: key,
    routeInformationProvider: config.routeInformationProvider,
    routeInformationParser: config.routeInformationParser,
    routerDelegate: config.routerDelegate,
    backButtonDispatcher: config.backButtonDispatcher,
    restorationScopeId: restorationScopeId,
  );
}