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
Jonny Borges
2019-12-02 19:19:18 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2019-12-02 19:19:18 -0300
Commit
b9ed5d059fc2c9c009b5bf988a1a7a8f5d3ce799
b9ed5d05
1 parent
419955b3
Update routes.dart
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
5 deletions
lib/src/routes.dart
lib/src/routes.dart
View file @
b9ed5d0
...
...
@@ -5,45 +5,89 @@ class Get {
static
Get
_get
;
static
GlobalKey
<
NavigatorState
>
key
=
new
GlobalKey
<
NavigatorState
>();
///Use Get.to instead of Navigator.push, Get.off instead of Navigator.pushReplacement,
///Get.offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named"
///after them. Example: Get.toNamed, Get.offNamed, and Get.AllNamed.
///To return to the previous screen, use Get.back().
///No need to pass any context to Get, just put the name of the route inside
///the parentheses and the magic will occur.
factory
Get
()
{
if
(
_get
==
null
)
_get
=
Get
.
_
();
return
_get
;
}
///Use Get.to instead of Navigator.push, Get.off instead of Navigator.pushReplacement,
///Get.offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named"
///after them. Example: Get.toNamed, Get.offNamed, and Get.AllNamed.
///To return to the previous screen, use Get.back().
///No need to pass any context to Get, just put the name of the route inside
///the parentheses and the magic will occur.
Get
.
_
();
/// It replaces Navigator.push, but needs no context, and it doesn't have the Navigator.push
/// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
/// of rebuilding every app after a route, use rebuildRoutes = true as the parameter.
static
to
(
Widget
page
,
{
bool
rebuildRoutes
=
false
})
{
return
key
.
currentState
.
push
(
GetRoute
(
opaque:
rebuildRoutes
,
builder:
(
_
)
=>
page
));
}
/// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed
/// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
/// of rebuilding every app after a route, use rebuildRoutes = true as the parameter.
static
toNamed
(
String
page
,
{
arguments
})
{
return
key
.
currentState
.
pushNamed
(
page
,
arguments:
arguments
);
}
/// It replaces Navigator.pushReplacementNamed, but needs no context.
static
offNamed
(
String
page
,
{
arguments
})
{
return
key
.
currentState
.
pushReplacementNamed
(
page
,
arguments:
arguments
);
return
key
.
currentState
.
pushReplacementNamed
(
page
,
arguments:
arguments
);
}
/// It replaces Navigator.popUntil, but needs no context.
static
until
(
String
page
,
predicate
)
{
return
key
.
currentState
.
popUntil
(
predicate
);
}
/// It replaces Navigator.pushAndRemoveUntil, but needs no context.
static
offUntil
(
page
,
predicate
)
{
return
key
.
currentState
.
pushAndRemoveUntil
(
page
,
predicate
);
}
/// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context.
static
offNamedUntil
(
page
,
predicate
)
{
return
key
.
currentState
.
pushNamedAndRemoveUntil
(
page
,
predicate
);
}
/// It replaces Navigator.removeRoute, but needs no context.
static
removeRoute
(
route
)
{
return
key
.
currentState
.
removeRoute
(
route
);
}
/// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context.
static
offAllNamed
(
String
newRouteName
,
RoutePredicate
predicate
,
{
Object
arguments
,
arguments
,
})
{
return
key
.
currentState
.
pushNamedAndRemoveUntil
(
newRouteName
,
predicate
,
arguments:
arguments
);
}
static
back
()
{
return
key
.
currentState
.
pop
();
/// It replaces Navigator.pop, but needs no context.
static
back
({
result
})
{
return
key
.
currentState
.
pop
(
result
);
}
/// It replaces Navigator.pushReplacement, but needs no context, and it doesn't have the Navigator.pushReplacement
/// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
/// of rebuilding every app after a route, use rebuildRoutes = true as the parameter.
static
off
(
Widget
page
,
{
bool
rebuildRoutes
=
false
})
{
return
key
.
currentState
.
pushReplacement
(
GetRoute
(
opaque:
rebuildRoutes
,
builder:
(
_
)
=>
page
));
}
/// It replaces Navigator.pushAndRemoveUntil, but needs no context
static
offAll
(
Widget
page
,
RoutePredicate
predicate
,
{
bool
rebuildRoutes
=
false
})
{
return
key
.
currentState
.
pushAndRemoveUntil
(
...
...
Please
register
or
login
to post a comment