// ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:kalodings/calendar.dart'; import 'package:kalodings/food_entry_bloc.dart'; import 'package:kalodings/perday_widget.dart'; void main() { runApp(const MainApp()); } class MainApp extends StatelessWidget { const MainApp({super.key}); @override Widget build(BuildContext context) { return BlocProvider( create: (BuildContext context) { return FoodEntryBloc(FoodEntryState.init()); }, child: MaterialApp.router( theme: ThemeData.dark(), routerConfig: router, ), ); } } final router = GoRouter(routes: [ GoRoute( path: '/', name: 'perDayToday', builder: (context, state) { return PerDay(DateTime.now()); }), GoRoute( path: '/day', name: 'perDay', builder: (context, state) { DateTime day; if (state.extra == null || state.extra is! DateTime) { day = DateTime.now(); } else { day = state.extra as DateTime; } return PerDay(day); }), GoRoute( path: '/calendar', name: 'calendar', builder: (context, state) { return CalendarWidget(); }), ]);