45 lines
1.1 KiB
Dart
45 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../views/bar_screen_view.dart';
|
|
import '../views/history_screen_view.dart';
|
|
import '../views/product_form_view.dart';
|
|
import '../views/product_list_view.dart';
|
|
|
|
final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
|
|
|
|
final appRouter = GoRouter(
|
|
initialLocation: '/bar',
|
|
observers: [
|
|
routeObserver,
|
|
],
|
|
routes: [
|
|
GoRoute(
|
|
path: '/bar',
|
|
builder: (context, state) => const BarScreenView(),
|
|
),
|
|
|
|
GoRoute(
|
|
path: '/products',
|
|
builder: (context, state) => const ProductListView(),
|
|
routes: [
|
|
GoRoute(
|
|
path: 'new',
|
|
builder: (context, state) => const ProductFormView(),
|
|
),
|
|
GoRoute(
|
|
path: ':id/edit',
|
|
builder: (context, state) {
|
|
final productId = state.pathParameters['id']!;
|
|
|
|
return ProductFormView(productId: productId);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
GoRoute(
|
|
path: '/history',
|
|
builder: (context, state) => const HistoryScreenView(),
|
|
),
|
|
],
|
|
); |