onGenerateRoutes static method
Implementation
static Route onGenerateRoutes(RouteSettings settings) {
// Handle routes with arguments
switch (settings.name) {
case diagramSingleLine:
final projectId = settings.arguments is String
? settings.arguments as String
: settings.arguments?.toString() ?? '';
if (projectId.isEmpty) {
return _createRoute(const DashboardPage());
}
return _createRoute(SingleLineDiagramPage(
projectId: projectId,
title: 'Diagrama Unifilar',
));
case library:
final args = settings.arguments as Map<String, dynamic>? ?? {};
return _createRoute(BlocProvider(
create: (_) => sl<ComponentLibraryCubit>(),
child: ComponentLibraryPage(
isPicker: args['isPicker'] ?? false,
filterType: args['filterType'],
),
));
case budget:
final root = settings.arguments;
if (root == null) {
return _createRoute(const DashboardPage());
}
return _createRoute(BlocProvider(
create: (_) => sl<BudgetCubit>()..loadBudget(root as ElectricalNode),
child: const BudgetPage(),
));
default:
// Use cached route if available
final builder = _routes[settings.name];
if (builder != null) {
return _createRoute(
Builder(builder: (context) => builder(context)),
);
}
// Fallback to dashboard
return _createRoute(const DashboardPage());
}
}