Showing
2 changed files
with
10 additions
and
11 deletions
@@ -13,6 +13,7 @@ class HomeView extends GetView<HomeController> { | @@ -13,6 +13,7 @@ class HomeView extends GetView<HomeController> { | ||
13 | Widget build(BuildContext context) { | 13 | Widget build(BuildContext context) { |
14 | return GetRouterOutlet.builder( | 14 | return GetRouterOutlet.builder( |
15 | builder: (context, delegate, currentRoute) { | 15 | builder: (context, delegate, currentRoute) { |
16 | + //This router outlet handles the appbar and the bottom navigation bar | ||
16 | final title = currentRoute?.title; | 17 | final title = currentRoute?.title; |
17 | final currentName = currentRoute?.name; | 18 | final currentName = currentRoute?.name; |
18 | var currentIndex = 0; | 19 | var currentIndex = 0; |
@@ -26,7 +27,7 @@ class HomeView extends GetView<HomeController> { | @@ -26,7 +27,7 @@ class HomeView extends GetView<HomeController> { | ||
26 | centerTitle: true, | 27 | centerTitle: true, |
27 | ), | 28 | ), |
28 | body: GetRouterOutlet( | 29 | body: GetRouterOutlet( |
29 | - emptyStackPage: (delegate) => DashboardView(), | 30 | + emptyPage: (delegate) => DashboardView(), |
30 | pickPages: (currentNavStack) { | 31 | pickPages: (currentNavStack) { |
31 | // will take any route after home | 32 | // will take any route after home |
32 | final res = currentNavStack.pickAfterRoute(Routes.HOME); | 33 | final res = currentNavStack.pickAfterRoute(Routes.HOME); |
@@ -39,33 +40,31 @@ class HomeView extends GetView<HomeController> { | @@ -39,33 +40,31 @@ class HomeView extends GetView<HomeController> { | ||
39 | bottomNavigationBar: BottomNavigationBar( | 40 | bottomNavigationBar: BottomNavigationBar( |
40 | currentIndex: currentIndex, | 41 | currentIndex: currentIndex, |
41 | onTap: (value) { | 42 | onTap: (value) { |
42 | - final getDelegate = Get.getDelegate(); | ||
43 | - if (getDelegate == null) return; | ||
44 | switch (value) { | 43 | switch (value) { |
45 | case 0: | 44 | case 0: |
46 | - getDelegate.offUntil(Routes.HOME); | 45 | + delegate.offUntil(Routes.HOME); |
47 | break; | 46 | break; |
48 | case 1: | 47 | case 1: |
49 | - getDelegate.toNamed(Routes.PROFILE); | 48 | + delegate.toNamed(Routes.PROFILE); |
50 | break; | 49 | break; |
51 | case 2: | 50 | case 2: |
52 | - getDelegate.toNamed(Routes.PRODUCTS); | 51 | + delegate.toNamed(Routes.PRODUCTS); |
53 | break; | 52 | break; |
54 | default: | 53 | default: |
55 | } | 54 | } |
56 | }, | 55 | }, |
57 | items: [ | 56 | items: [ |
58 | - // Routes.Home + [Empty] | 57 | + // _Paths.HOME + [Empty] |
59 | BottomNavigationBarItem( | 58 | BottomNavigationBarItem( |
60 | icon: Icon(Icons.home), | 59 | icon: Icon(Icons.home), |
61 | label: 'Home', | 60 | label: 'Home', |
62 | ), | 61 | ), |
63 | - // Routes.Home + Routes.Profile | 62 | + // _Paths.HOME + Routes.PROFILE |
64 | BottomNavigationBarItem( | 63 | BottomNavigationBarItem( |
65 | icon: Icon(Icons.account_box_rounded), | 64 | icon: Icon(Icons.account_box_rounded), |
66 | label: 'Profile', | 65 | label: 'Profile', |
67 | ), | 66 | ), |
68 | - // Routes.Home + Routes.Products | 67 | + // _Paths.HOME + _Paths.PRODUCTS |
69 | BottomNavigationBarItem( | 68 | BottomNavigationBarItem( |
70 | icon: Icon(Icons.account_box_rounded), | 69 | icon: Icon(Icons.account_box_rounded), |
71 | label: 'Products', | 70 | label: 'Products', |
@@ -83,7 +83,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetPage> { | @@ -83,7 +83,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetPage> { | ||
83 | ); | 83 | ); |
84 | 84 | ||
85 | GetRouterOutlet({ | 85 | GetRouterOutlet({ |
86 | - Widget Function(GetDelegate delegate)? emptyStackPage, | 86 | + Widget Function(GetDelegate delegate)? emptyPage, |
87 | required List<GetPage> Function(List<GetPage> currentNavStack) pickPages, | 87 | required List<GetPage> Function(List<GetPage> currentNavStack) pickPages, |
88 | }) : super( | 88 | }) : super( |
89 | pageBuilder: (context, rDelegate, page) { | 89 | pageBuilder: (context, rDelegate, page) { |
@@ -97,7 +97,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetPage> { | @@ -97,7 +97,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetPage> { | ||
97 | } | 97 | } |
98 | 98 | ||
99 | /// improve this logic abit | 99 | /// improve this logic abit |
100 | - return (emptyStackPage?.call(rDelegate) ?? | 100 | + return (emptyPage?.call(rDelegate) ?? |
101 | rDelegate.notFoundRoute?.page()) ?? | 101 | rDelegate.notFoundRoute?.page()) ?? |
102 | SizedBox.shrink(); | 102 | SizedBox.shrink(); |
103 | }, | 103 | }, |
-
Please register or login to post a comment