buildDynamicRoutes method
void
buildDynamicRoutes()
Implementation
void buildDynamicRoutes() {
if (usesRouter ||
(widget.home is! ArcaneRoute && widget.arcaneRoutes.isEmpty)) {
return;
}
info("=== Building Dynamic Route Map ===");
dynamicRoutes = {...(widget.routes ?? {})};
for (ArcaneRoute route in widget.arcaneRoutes) {
dynamicRoutes[route.path] = (context) => route;
verbose("${route.path} -> ${route.runtimeType}");
}
if (!dynamicRoutes.containsKey(widget.initialRoute) &&
widget.home is ArcaneRoute) {
dynamicRoutes[widget.initialRoute] = (context) => widget.home!;
verbose("${widget.initialRoute} -> ${widget.home!.runtimeType}");
}
routeFactory = (RouteSettings settings) {
if (settings.name?.isNotEmpty ?? false) {
String route = Uri.parse(settings.name!).path;
if (dynamicRoutes.containsKey(route)) {
return MaterialPageRoute(
builder: dynamicRoutes[route]!, settings: settings);
}
}
return null;
};
usesArcaneRouting = true;
}