calorimeter/lib/utils/router.dart

29 lines
740 B
Dart
Raw Normal View History

2024-09-06 11:48:56 +00:00
import 'package:calodiary/perdate/perdate_widget.dart';
import 'package:calodiary/utils/settings.dart';
import 'package:go_router/go_router.dart';
GoRouter getRouterConfig() {
return GoRouter(initialLocation: '/day', routes: [
GoRoute(
path: '/day',
name: 'perDay',
builder: (context, state) {
DateTime date;
if (state.extra == null || state.extra is! DateTime) {
date = DateTime.now();
} else {
date = state.extra as DateTime;
}
return PerDateWidget(date: date);
}),
GoRoute(
path: '/settings',
name: 'settings',
builder: (context, state) {
return const SettingsWidget();
},
)
]);
}