ArcaneApp.router constructor

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

Creates an ArcaneApp with the Router API for declarative, advanced navigation.

This constructor leverages Flutter's Router system for URL-based routing, stateful navigation, and deep linking, using RouterDelegate and RouteInformationParser to manage routes. It integrates ArcaneTheme and supports components like NavigationScreen for complex, history-aware UIs. Suited for web apps or those needing browser integration, with performance benefits from reactive route updates without full rebuilds.

Parameters:

  • key: Standard Flutter widget key for identification and state management.
  • theme: Optional ArcaneTheme to apply app-wide styling; defaults to a basic theme if null.
  • routeInformationProvider: RouteInformationProvider for listening to route changes (e.g., from browser).
  • routeInformationParser: RouteInformationParser to parse route info into app state; essential for URL handling.
  • routerDelegate: RouterDelegate to build pages and manage navigation stack based on state.
  • routerConfig: Alternative RouterConfig for simplified router setup; mutually exclusive with delegate/parser.
  • backButtonDispatcher: BackButtonDispatcher for handling system back gestures.
  • builder: TransitionBuilder to wrap the router output, e.g., for global providers or theming.
  • title: App title for system bars and accessibility; used in GenerateAppTitle if provided.
  • onGenerateTitle: Dynamic title generator based on BuildContext; overrides static title.
  • onNavigationNotification: Listener for NavigationNotification events, e.g., to track route changes.
  • color: Primary Color for system UI (e.g., status bar); integrates with ArcaneTheme.
  • locale: Initial app Locale; affects Localizations and right-to-left layouts.
  • localizationsDelegates: Iterable of LocalizationsDelegates for i18n support; enables Localizations.
  • localeListResolutionCallback: Resolves conflicting locales from device and app lists.
  • localeResolutionCallback: Selects the best Locale from supported ones based on device settings.
  • supportedLocales: List of Locales the app handles; defaults to English (US) for broad compatibility.
  • debugShowMaterialGrid: Toggles Material Design grid overlay for layout debugging.
  • showPerformanceOverlay: Enables performance metrics overlay to monitor frame rates and rebuilds.
  • showSemanticsDebugger: Shows semantic tree for accessibility testing.
  • debugShowCheckedModeBanner: Displays "DEBUG" banner in debug mode; defaults to true for router debugging.
  • shortcuts: Map of ShortcutActivator to Intent for keyboard navigation support.
  • actions: Map of Intent types to Actions for handling user inputs.
  • restorationScopeId: ID for state restoration across app restarts (e.g., for Hive integration).
  • scaling: Optional AdaptiveScaling for responsive UI adjustments across devices.
  • disableBrowserContextMenu: Prevents web context menu for native app feel; defaults to true.

Returns: A configured ArcaneApp for router-based navigation, with optimized state syncing between URL and UI, supporting deep links to screens like ChatScreen or FillScreen efficiently.

Implementation

const ArcaneApp.router({
  super.key,
  this.theme,
  this.routeInformationProvider,
  this.routeInformationParser,
  this.routerDelegate,
  this.routerConfig,
  this.backButtonDispatcher,
  this.builder,
  this.title = '',
  this.onGenerateTitle,
  this.onNavigationNotification,
  this.color,
  this.locale,
  this.localizationsDelegates,
  this.localeListResolutionCallback,
  this.localeResolutionCallback,
  this.supportedLocales = const <Locale>[Locale('en', 'US')],
  this.debugShowMaterialGrid = false,
  this.showPerformanceOverlay = false,
  this.showSemanticsDebugger = false,
  this.debugShowCheckedModeBanner = true,
  this.shortcuts,
  this.actions,
  this.restorationScopeId,
  this.scaling,
  this.disableBrowserContextMenu = true,
})  : assert(routerDelegate != null || routerConfig != null),
      navigatorObservers = null,
      navigatorKey = null,
      onGenerateRoute = null,
      home = null,
      onGenerateInitialRoutes = null,
      onUnknownRoute = null,
      routes = null,
      initialRoute = "/";