Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Ahmed Fwela
2021-05-31 15:17:30 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
322e97389668ad315fe66f3f37300d64c7f8c5cc
322e9738
1 parent
240a9954
added some comments to the example
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
11 deletions
example_nav2/lib/app/modules/home/views/home_view.dart
lib/get_navigation/src/nav2/router_outlet.dart
example_nav2/lib/app/modules/home/views/home_view.dart
View file @
322e973
...
...
@@ -13,6 +13,7 @@ class HomeView extends GetView<HomeController> {
Widget
build
(
BuildContext
context
)
{
return
GetRouterOutlet
.
builder
(
builder:
(
context
,
delegate
,
currentRoute
)
{
//This router outlet handles the appbar and the bottom navigation bar
final
title
=
currentRoute
?.
title
;
final
currentName
=
currentRoute
?.
name
;
var
currentIndex
=
0
;
...
...
@@ -26,7 +27,7 @@ class HomeView extends GetView<HomeController> {
centerTitle:
true
,
),
body:
GetRouterOutlet
(
empty
Stack
Page:
(
delegate
)
=>
DashboardView
(),
emptyPage:
(
delegate
)
=>
DashboardView
(),
pickPages:
(
currentNavStack
)
{
// will take any route after home
final
res
=
currentNavStack
.
pickAfterRoute
(
Routes
.
HOME
);
...
...
@@ -39,33 +40,31 @@ class HomeView extends GetView<HomeController> {
bottomNavigationBar:
BottomNavigationBar
(
currentIndex:
currentIndex
,
onTap:
(
value
)
{
final
getDelegate
=
Get
.
getDelegate
();
if
(
getDelegate
==
null
)
return
;
switch
(
value
)
{
case
0
:
getD
elegate
.
offUntil
(
Routes
.
HOME
);
d
elegate
.
offUntil
(
Routes
.
HOME
);
break
;
case
1
:
getD
elegate
.
toNamed
(
Routes
.
PROFILE
);
d
elegate
.
toNamed
(
Routes
.
PROFILE
);
break
;
case
2
:
getD
elegate
.
toNamed
(
Routes
.
PRODUCTS
);
d
elegate
.
toNamed
(
Routes
.
PRODUCTS
);
break
;
default
:
}
},
items:
[
//
Routes.Home
+ [Empty]
//
_Paths.HOME
+ [Empty]
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
home
),
label:
'Home'
,
),
//
Routes.Home + Routes.Profile
//
_Paths.HOME + Routes.PROFILE
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
account_box_rounded
),
label:
'Profile'
,
),
//
Routes.Home + Routes.Products
//
_Paths.HOME + _Paths.PRODUCTS
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
account_box_rounded
),
label:
'Products'
,
...
...
lib/get_navigation/src/nav2/router_outlet.dart
View file @
322e973
...
...
@@ -83,7 +83,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetPage> {
);
GetRouterOutlet
({
Widget
Function
(
GetDelegate
delegate
)?
empty
Stack
Page
,
Widget
Function
(
GetDelegate
delegate
)?
emptyPage
,
required
List
<
GetPage
>
Function
(
List
<
GetPage
>
currentNavStack
)
pickPages
,
})
:
super
(
pageBuilder:
(
context
,
rDelegate
,
page
)
{
...
...
@@ -97,7 +97,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetPage> {
}
/// improve this logic abit
return
(
empty
Stack
Page
?.
call
(
rDelegate
)
??
return
(
emptyPage
?.
call
(
rDelegate
)
??
rDelegate
.
notFoundRoute
?.
page
())
??
SizedBox
.
shrink
();
},
...
...
Please
register
or
login
to post a comment