Showing
7 changed files
with
54 additions
and
20 deletions
| 1 | +## [4.3.7] | ||
| 2 | +- Fix wrong currentRoute when a route is removed | ||
| 3 | +- Remove take that limits the router outlet depth (@steven-spiel) | ||
| 4 | + | ||
| 1 | ## [4.3.6] | 5 | ## [4.3.6] | 
| 2 | - Fix error with autodispose of additional dependencies beyond GetxController | 6 | - Fix error with autodispose of additional dependencies beyond GetxController | 
| 3 | - Added ability to add your own delegate to RouterOutlet (@steven-spiel) | 7 | - Added ability to add your own delegate to RouterOutlet (@steven-spiel) | 
| @@ -70,8 +70,10 @@ class HomeView extends GetView<HomeController> { | @@ -70,8 +70,10 @@ class HomeView extends GetView<HomeController> { | ||
| 70 | ), | 70 | ), | 
| 71 | shape: StadiumBorder(), | 71 | shape: StadiumBorder(), | 
| 72 | ), | 72 | ), | 
| 73 | - onPressed: () { | ||
| 74 | - Get.rootDelegate.toNamed('/home/country'); | 73 | + onPressed: () async { | 
| 74 | + final data = | ||
| 75 | + await Get.rootDelegate.toNamed('/home/country'); | ||
| 76 | + print('DATA: $data'); | ||
| 75 | }, | 77 | }, | 
| 76 | child: Text( | 78 | child: Text( | 
| 77 | 'fetch_country'.tr, | 79 | 'fetch_country'.tr, | 
| @@ -334,26 +334,48 @@ class GetDelegate extends RouterDelegate<GetNavConfig> | @@ -334,26 +334,48 @@ class GetDelegate extends RouterDelegate<GetNavConfig> | ||
| 334 | 334 | ||
| 335 | final completer = Completer<T>(); | 335 | final completer = Completer<T>(); | 
| 336 | 336 | ||
| 337 | - _allCompleters[decoder.route!] = completer; | ||
| 338 | - | ||
| 339 | - pushHistory( | ||
| 340 | - GetNavConfig( | ||
| 341 | - currentTreeBranch: decoder.treeBranch, | ||
| 342 | - location: page, | ||
| 343 | - state: null, //TODO: persist state? | ||
| 344 | - ), | ||
| 345 | - ); | 337 | + if (decoder.route != null) { | 
| 338 | + _allCompleters[decoder.route!] = completer; | ||
| 339 | + await pushHistory( | ||
| 340 | + GetNavConfig( | ||
| 341 | + currentTreeBranch: decoder.treeBranch, | ||
| 342 | + location: page, | ||
| 343 | + state: null, //TODO: persist state? | ||
| 344 | + ), | ||
| 345 | + ); | ||
| 346 | + | ||
| 347 | + return completer.future; | ||
| 348 | + } else { | ||
| 349 | + ///TODO: IMPLEMENT ROUTE NOT FOUND | ||
| 350 | + | ||
| 351 | + return Future.value(); | ||
| 352 | + } | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + Future<T?>? offAndToNamed<T>( | ||
| 356 | + String page, { | ||
| 357 | + dynamic arguments, | ||
| 358 | + int? id, | ||
| 359 | + dynamic result, | ||
| 360 | + Map<String, String>? parameters, | ||
| 361 | + PopMode popMode = PopMode.History, | ||
| 362 | + }) async { | ||
| 363 | + if (parameters != null) { | ||
| 364 | + final uri = Uri(path: page, queryParameters: parameters); | ||
| 365 | + page = uri.toString(); | ||
| 366 | + } | ||
| 346 | 367 | ||
| 347 | - return completer.future; | 368 | + await popRoute(result: result); | 
| 369 | + return toNamed(page, arguments: arguments, parameters: parameters); | ||
| 348 | } | 370 | } | 
| 349 | 371 | ||
| 350 | - Future<void> offNamed( | 372 | + Future<T> offNamed<T>( | 
| 351 | String page, { | 373 | String page, { | 
| 352 | dynamic arguments, | 374 | dynamic arguments, | 
| 353 | Map<String, String>? parameters, | 375 | Map<String, String>? parameters, | 
| 354 | }) async { | 376 | }) async { | 
| 355 | - await toNamed(page, arguments: arguments, parameters: parameters); | ||
| 356 | - await _unsafeHistoryRemoveAt(history.length - 2); | 377 | + history.removeLast(); | 
| 378 | + return toNamed<T>(page, arguments: arguments, parameters: parameters); | ||
| 357 | } | 379 | } | 
| 358 | 380 | ||
| 359 | /// Removes routes according to [PopMode] | 381 | /// Removes routes according to [PopMode] | 
| @@ -422,8 +444,12 @@ class GetDelegate extends RouterDelegate<GetNavConfig> | @@ -422,8 +444,12 @@ class GetDelegate extends RouterDelegate<GetNavConfig> | ||
| 422 | if (config != null) { | 444 | if (config != null) { | 
| 423 | _removeHistoryEntry(config); | 445 | _removeHistoryEntry(config); | 
| 424 | } | 446 | } | 
| 447 | + if (_allCompleters.containsKey(settings)) { | ||
| 448 | + _allCompleters[settings]?.complete(route.popped); | ||
| 449 | + } | ||
| 425 | } | 450 | } | 
| 426 | refresh(); | 451 | refresh(); | 
| 452 | + | ||
| 427 | return true; | 453 | return true; | 
| 428 | } | 454 | } | 
| 429 | } | 455 | } | 
| @@ -88,9 +88,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> { | @@ -88,9 +88,7 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, GetNavConfig> { | ||
| 88 | if (anchorRoute == null) { | 88 | if (anchorRoute == null) { | 
| 89 | // jump the ancestor path | 89 | // jump the ancestor path | 
| 90 | final length = Uri.parse(initialRoute).pathSegments.length; | 90 | final length = Uri.parse(initialRoute).pathSegments.length; | 
| 91 | - return config.currentTreeBranch | ||
| 92 | - .skip(length) | ||
| 93 | - .toList(); | 91 | + return config.currentTreeBranch.skip(length).toList(); | 
| 94 | } | 92 | } | 
| 95 | ret = config.currentTreeBranch.pickAfterRoute(anchorRoute); | 93 | ret = config.currentTreeBranch.pickAfterRoute(anchorRoute); | 
| 96 | if (filterPages != null) { | 94 | if (filterPages != null) { | 
| @@ -174,6 +174,8 @@ class GetPage<T> extends Page<T> { | @@ -174,6 +174,8 @@ class GetPage<T> extends Page<T> { | ||
| 174 | ); | 174 | ); | 
| 175 | } | 175 | } | 
| 176 | 176 | ||
| 177 | + late Future<T?> popped; | ||
| 178 | + | ||
| 177 | @override | 179 | @override | 
| 178 | Route<T> createRoute(BuildContext context) { | 180 | Route<T> createRoute(BuildContext context) { | 
| 179 | // return GetPageRoute<T>(settings: this, page: page); | 181 | // return GetPageRoute<T>(settings: this, page: page); | 
| @@ -182,6 +184,8 @@ class GetPage<T> extends Page<T> { | @@ -182,6 +184,8 @@ class GetPage<T> extends Page<T> { | ||
| 182 | settings: this, | 184 | settings: this, | 
| 183 | unknownRoute: unknownRoute, | 185 | unknownRoute: unknownRoute, | 
| 184 | ).getPageToRoute<T>(this, unknownRoute); | 186 | ).getPageToRoute<T>(this, unknownRoute); | 
| 187 | + | ||
| 188 | + popped = _page.popped; | ||
| 185 | return _page; | 189 | return _page; | 
| 186 | } | 190 | } | 
| 187 | } | 191 | } | 
| @@ -156,7 +156,7 @@ class GetObserver extends NavigatorObserver { | @@ -156,7 +156,7 @@ class GetObserver extends NavigatorObserver { | ||
| 156 | value.current = _extractRouteName(previousRoute) ?? ''; | 156 | value.current = _extractRouteName(previousRoute) ?? ''; | 
| 157 | } | 157 | } | 
| 158 | 158 | ||
| 159 | - value.args = previousRoute.settings.arguments; | 159 | + value.args = previousRoute?.settings.arguments; | 
| 160 | value.route = previousRoute; | 160 | value.route = previousRoute; | 
| 161 | value.isBack = true; | 161 | value.isBack = true; | 
| 162 | value.removed = ''; | 162 | value.removed = ''; | 
| 1 | name: get | 1 | name: get | 
| 2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. | 
| 3 | -version: 4.3.6 | 3 | +version: 4.3.7 | 
| 4 | homepage: https://github.com/jonataslaw/getx | 4 | homepage: https://github.com/jonataslaw/getx | 
| 5 | 5 | ||
| 6 | environment: | 6 | environment: | 
- 
Please register or login to post a comment