dvRouterConfig<T extends Object> function
RouterConfig<Object>
dvRouterConfig<T extends Object>(
- List<
RouteBase> routes, { - String at = '/',
- RouterConfig<
T> ? existing,
For MaterialApp.router and CupertinoApp.router: the app's own
existing RouterConfig composed with Dartvel's routes under at.
A location that is one of Dartvel's paths is Dartvel's, and runs its whole
route table; any other is parsed by existing's parser and handed to
existing's delegate, in existing's own configuration type. The app's
screens stay built while a Dartvel page shows, and back from Dartvel's
first page returns to them. With no existing, the config is Dartvel's
alone.
Implementation
RouterConfig<Object> dvRouterConfig<T extends Object>(
List<RouteBase> routes, {
String at = '/',
RouterConfig<T>? existing,
}) {
if (existing == null) {
final GoRouter router = GoRouter(routes: dvMountRoutes(routes, at: at));
DVNavigation.attach(router);
return router;
}
final RouteInformationParser<T>? parser = existing.routeInformationParser;
if (parser == null) {
throw ArgumentError.value(
existing,
'existing',
'has no routeInformationParser, so the locations that are not '
"Dartvel's cannot be handed to it",
);
}
final RouteInformationProvider? provider = existing.routeInformationProvider;
return RouterConfig<Object>(
routeInformationProvider: provider == null
? PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(
uri: Uri.parse(
WidgetsBinding.instance.platformDispatcher.defaultRouteName,
),
),
)
: _DVComposedProvider(provider, routes, at),
routeInformationParser: _DVComposedParser<T>(routes, at, parser),
routerDelegate: _DVComposedDelegate<T>(routes, at, existing.routerDelegate),
backButtonDispatcher:
existing.backButtonDispatcher ?? RootBackButtonDispatcher(),
);
}