ArcaneApp.router constructor
const
ArcaneApp.router({
- Key? key,
- ArcaneTheme? theme,
- RouteInformationProvider? routeInformationProvider,
- RouteInformationParser<
Object> ? routeInformationParser, - RouterDelegate<
Object> ? routerDelegate, - RouterConfig<
Object> ? routerConfig, - BackButtonDispatcher? backButtonDispatcher,
- TransitionBuilder? builder,
- String title = '',
- GenerateAppTitle? onGenerateTitle,
- Color? color,
- Locale? locale,
- Iterable<
LocalizationsDelegate> ? localizationsDelegates, - LocaleListResolutionCallback? localeListResolutionCallback,
- LocaleResolutionCallback? localeResolutionCallback,
- Iterable<
Locale> supportedLocales = const <Locale>[Locale('en', 'US')], - bool debugShowMaterialGrid = false,
- bool showPerformanceOverlay = false,
- bool showSemanticsDebugger = false,
- bool debugShowCheckedModeBanner = true,
- Map<
ShortcutActivator, Intent> ? shortcuts, - Map<
Type, Action< ? actions,Intent> > - String? restorationScopeId,
- AdaptiveScaling? scaling,
- 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 = "/";