WidgetsApp.router constructor Null safety

WidgetsApp.router(
  1. {Key? key,
  2. RouteInformationProvider? routeInformationProvider,
  3. RouteInformationParser<Object>? routeInformationParser,
  4. RouterDelegate<Object>? routerDelegate,
  5. RouterConfig<Object>? routerConfig,
  6. BackButtonDispatcher? backButtonDispatcher,
  7. TransitionBuilder? builder,
  8. String title = '',
  9. GenerateAppTitle? onGenerateTitle,
  10. TextStyle? textStyle,
  11. required Color color,
  12. Locale? locale,
  13. Iterable<LocalizationsDelegate>? localizationsDelegates,
  14. LocaleListResolutionCallback? localeListResolutionCallback,
  15. LocaleResolutionCallback? localeResolutionCallback,
  16. Iterable<Locale> supportedLocales = const <Locale>[Locale('en', 'US')],
  17. bool showPerformanceOverlay = false,
  18. bool checkerboardRasterCacheImages = false,
  19. bool checkerboardOffscreenLayers = false,
  20. bool showSemanticsDebugger = false,
  21. bool debugShowWidgetInspector = false,
  22. bool debugShowCheckedModeBanner = true,
  23. InspectorSelectButtonBuilder? inspectorSelectButtonBuilder,
  24. Map<ShortcutActivator, Intent>? shortcuts,
  25. Map<Type, Action<Intent>>? actions,
  26. String? restorationScopeId,
  27. bool useInheritedMediaQuery = false}
)

Creates a WidgetsApp that uses the Router instead of a Navigator.

If the routerConfig is provided, the other router related delegates, routeInformationParser, routeInformationProvider, routerDelegate, and backButtonDispatcher, must all be null.

Implementation

WidgetsApp.router({
  super.key,
  this.routeInformationProvider,
  this.routeInformationParser,
  this.routerDelegate,
  this.routerConfig,
  this.backButtonDispatcher,
  this.builder,
  this.title = '',
  this.onGenerateTitle,
  this.textStyle,
  required this.color,
  this.locale,
  this.localizationsDelegates,
  this.localeListResolutionCallback,
  this.localeResolutionCallback,
  this.supportedLocales = const <Locale>[Locale('en', 'US')],
  this.showPerformanceOverlay = false,
  this.checkerboardRasterCacheImages = false,
  this.checkerboardOffscreenLayers = false,
  this.showSemanticsDebugger = false,
  this.debugShowWidgetInspector = false,
  this.debugShowCheckedModeBanner = true,
  this.inspectorSelectButtonBuilder,
  this.shortcuts,
  this.actions,
  this.restorationScopeId,
  this.useInheritedMediaQuery = false,
}) : assert((){
       if (routerConfig != null) {
         assert(
           (routeInformationProvider ?? routeInformationParser ?? routerDelegate ?? backButtonDispatcher) == null,
           'If the routerConfig is provided, all the other router delegates must not be provided',
         );
         return true;
       }
       assert(routerDelegate != null, 'Either one of routerDelegate or routerConfig must be provided');
       assert(
         routeInformationProvider == null || routeInformationParser != null,
         'If routeInformationProvider is provided, routeInformationParser must also be provided',
       );
       return true;
     }()),
     assert(title != null),
     assert(color != null),
     assert(supportedLocales != null && supportedLocales.isNotEmpty),
     assert(showPerformanceOverlay != null),
     assert(checkerboardRasterCacheImages != null),
     assert(checkerboardOffscreenLayers != null),
     assert(showSemanticsDebugger != null),
     assert(debugShowCheckedModeBanner != null),
     assert(debugShowWidgetInspector != null),
     navigatorObservers = null,
     navigatorKey = null,
     onGenerateRoute = null,
     pageRouteBuilder = null,
     home = null,
     onGenerateInitialRoutes = null,
     onUnknownRoute = null,
     routes = null,
     initialRoute = null;