/
dashboard_routes.dart
67 lines (64 loc) · 2.04 KB
/
dashboard_routes.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import 'package:qlevar_router/qlevar_router.dart';
import '../pages/dashboard/dashboard_view.dart';
import '../pages/dashboard/home_view.dart';
import '../pages/dashboard/products_view.dart';
import '../pages/store/product_view.dart';
import '../pages/store/store_view.dart';
import '../pages/store/stores_view.dart';
import 'middleware/auth_middleware.dart';
class DashboardRoutes {
static const String dashboard = 'dashboard';
static const String dashboardHome = 'dashboard_home';
static const String dashboardStores = 'dashboard_stores';
static const String dashboardStoresId = 'dashboard_stores_id';
static const String dashboardStoreIdProduct = 'dashboard_store_id_product';
static const String dashboardProducts = 'dashboard_products';
final route = QRoute.withChild(
path: '/dashboard',
name: dashboard,
initRoute: '/home',
meta: {
'title': 'Dashboard',
},
middleware: [
// Set the auth middleware to allow only to the logged in users
// to access the dashboard, the children routes will be protected
// by this middleware too
AuthMiddleware(),
],
builderChild: (router) => DashboardView(router: router),
children: [
QRoute(
path: '/home',
name: dashboardHome,
builder: () => HomeView(),
),
QRoute(
path: '/stores',
name: dashboardStores,
builder: () => StoresView(fromDashboard: true),
children: [
QRoute(
path: '/:id',
name: dashboardStoresId,
pageType: const QCupertinoPage(),
builder: () => StoreView(fromDashboard: true),
children: [
QRoute(
path: '/product/:product_id',
name: dashboardStoreIdProduct,
pageType: const QMaterialPage(),
builder: () => ProductView(),
),
],
),
],
),
QRoute(
path: '/products',
name: dashboardProducts,
builder: () => ProductsView(),
),
],
);
}