Committed by
GitHub
Merge pull request #1667 from jonataslaw/router-fix
fix router outlet
Showing
3 changed files
with
18 additions
and
12 deletions
@@ -20,9 +20,9 @@ class RootView extends GetView<RootController> { | @@ -20,9 +20,9 @@ class RootView extends GetView<RootController> { | ||
20 | body: GetRouterOutlet( | 20 | body: GetRouterOutlet( |
21 | initialRoute: Routes.HOME, | 21 | initialRoute: Routes.HOME, |
22 | // anchorRoute: '/', | 22 | // anchorRoute: '/', |
23 | - filterPages: (afterAnchor) { | ||
24 | - return afterAnchor.take(1); | ||
25 | - }, | 23 | + // filterPages: (afterAnchor) { |
24 | + // return afterAnchor.take(1); | ||
25 | + // }, | ||
26 | ), | 26 | ), |
27 | ); | 27 | ); |
28 | }, | 28 | }, |
@@ -85,16 +85,14 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> { | @@ -85,16 +85,14 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> { | ||
85 | pickPages: (config) { | 85 | pickPages: (config) { |
86 | Iterable<GetPage<dynamic>> ret; | 86 | Iterable<GetPage<dynamic>> ret; |
87 | if (anchorRoute == null) { | 87 | if (anchorRoute == null) { |
88 | - //anchorRoute = initialRoute minus last segment | ||
89 | - final parsedUri = Uri.parse(initialRoute); | ||
90 | - final replacedUri = parsedUri.replace( | ||
91 | - pathSegments: parsedUri.pathSegments.take( | ||
92 | - parsedUri.pathSegments.length - 1, | ||
93 | - ), | ||
94 | - ); | ||
95 | - anchorRoute = '/$replacedUri'; | 88 | + // jump the ancestor path |
89 | + final length = Uri.parse(initialRoute).pathSegments.length; | ||
90 | + return config.currentTreeBranch | ||
91 | + .skip(length) | ||
92 | + .take(length) | ||
93 | + .toList(); | ||
96 | } | 94 | } |
97 | - ret = config.currentTreeBranch.pickAfterRoute(anchorRoute!); | 95 | + ret = config.currentTreeBranch.pickAfterRoute(anchorRoute); |
98 | if (filterPages != null) { | 96 | if (filterPages != null) { |
99 | ret = filterPages(ret); | 97 | ret = filterPages(ret); |
100 | } | 98 | } |
-
Please register or login to post a comment