Showing
2 changed files
with
50 additions
and
31 deletions
@@ -541,24 +541,22 @@ extension GetNavigation on GetInterface { | @@ -541,24 +541,22 @@ extension GetNavigation on GetInterface { | ||
541 | String page, { | 541 | String page, { |
542 | dynamic arguments, | 542 | dynamic arguments, |
543 | int id, | 543 | int id, |
544 | - Map<String, String> parameters, | ||
545 | bool preventDuplicates = true, | 544 | bool preventDuplicates = true, |
545 | + Map<String, String> parameters, | ||
546 | }) { | 546 | }) { |
547 | - Get.parameters = ({}); | ||
548 | - if (parameters != null) { | ||
549 | - for (var item in parameters.keys) { | ||
550 | - if (page.contains('?')) { | ||
551 | - page += "&$item=${parameters[item]}"; | ||
552 | - } else { | ||
553 | - page += "?$item=${parameters[item]}"; | ||
554 | - } | ||
555 | - } | ||
556 | - } | ||
557 | - | ||
558 | if (preventDuplicates && page == currentRoute) { | 547 | if (preventDuplicates && page == currentRoute) { |
559 | return null; | 548 | return null; |
560 | } | 549 | } |
561 | - return global(id)?.currentState?.pushNamed<T>(page, arguments: arguments); | 550 | + |
551 | + if (parameters != null) { | ||
552 | + final uri = Uri(path: page, queryParameters: parameters); | ||
553 | + page = uri.toString(); | ||
554 | + } | ||
555 | + | ||
556 | + return global(id)?.currentState?.pushNamed<T>( | ||
557 | + page, | ||
558 | + arguments: arguments, | ||
559 | + ); | ||
562 | } | 560 | } |
563 | 561 | ||
564 | /// **Navigation.pushReplacementNamed()** shortcut.<br><br> | 562 | /// **Navigation.pushReplacementNamed()** shortcut.<br><br> |
@@ -582,13 +580,20 @@ extension GetNavigation on GetInterface { | @@ -582,13 +580,20 @@ extension GetNavigation on GetInterface { | ||
582 | dynamic arguments, | 580 | dynamic arguments, |
583 | int id, | 581 | int id, |
584 | bool preventDuplicates = true, | 582 | bool preventDuplicates = true, |
583 | + Map<String, String> parameters, | ||
585 | }) { | 584 | }) { |
586 | if (preventDuplicates && page == currentRoute) { | 585 | if (preventDuplicates && page == currentRoute) { |
587 | return null; | 586 | return null; |
588 | } | 587 | } |
589 | - return global(id) | ||
590 | - ?.currentState | ||
591 | - ?.pushReplacementNamed(page, arguments: arguments); | 588 | + |
589 | + if (parameters != null) { | ||
590 | + final uri = Uri(path: page, queryParameters: parameters); | ||
591 | + page = uri.toString(); | ||
592 | + } | ||
593 | + return global(id)?.currentState?.pushReplacementNamed( | ||
594 | + page, | ||
595 | + arguments: arguments, | ||
596 | + ); | ||
592 | } | 597 | } |
593 | 598 | ||
594 | /// **Navigation.popUntil()** shortcut.<br><br> | 599 | /// **Navigation.popUntil()** shortcut.<br><br> |
@@ -657,10 +662,18 @@ extension GetNavigation on GetInterface { | @@ -657,10 +662,18 @@ extension GetNavigation on GetInterface { | ||
657 | RoutePredicate predicate, { | 662 | RoutePredicate predicate, { |
658 | int id, | 663 | int id, |
659 | dynamic arguments, | 664 | dynamic arguments, |
665 | + Map<String, String> parameters, | ||
660 | }) { | 666 | }) { |
661 | - return global(id) | ||
662 | - ?.currentState | ||
663 | - ?.pushNamedAndRemoveUntil<T>(page, predicate, arguments: arguments); | 667 | + if (parameters != null) { |
668 | + final uri = Uri(path: page, queryParameters: parameters); | ||
669 | + page = uri.toString(); | ||
670 | + } | ||
671 | + | ||
672 | + return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( | ||
673 | + page, | ||
674 | + predicate, | ||
675 | + arguments: arguments, | ||
676 | + ); | ||
664 | } | 677 | } |
665 | 678 | ||
666 | /// **Navigation.popAndPushNamed()** shortcut.<br><br> | 679 | /// **Navigation.popAndPushNamed()** shortcut.<br><br> |
@@ -679,10 +692,17 @@ extension GetNavigation on GetInterface { | @@ -679,10 +692,17 @@ extension GetNavigation on GetInterface { | ||
679 | dynamic arguments, | 692 | dynamic arguments, |
680 | int id, | 693 | int id, |
681 | dynamic result, | 694 | dynamic result, |
695 | + Map<String, String> parameters, | ||
682 | }) { | 696 | }) { |
683 | - return global(id) | ||
684 | - ?.currentState | ||
685 | - ?.popAndPushNamed(page, arguments: arguments, result: result); | 697 | + if (parameters != null) { |
698 | + final uri = Uri(path: page, queryParameters: parameters); | ||
699 | + page = uri.toString(); | ||
700 | + } | ||
701 | + return global(id)?.currentState?.popAndPushNamed( | ||
702 | + page, | ||
703 | + arguments: arguments, | ||
704 | + result: result, | ||
705 | + ); | ||
686 | } | 706 | } |
687 | 707 | ||
688 | /// **Navigation.removeRoute()** shortcut.<br><br> | 708 | /// **Navigation.removeRoute()** shortcut.<br><br> |
@@ -720,7 +740,13 @@ extension GetNavigation on GetInterface { | @@ -720,7 +740,13 @@ extension GetNavigation on GetInterface { | ||
720 | RoutePredicate predicate, | 740 | RoutePredicate predicate, |
721 | dynamic arguments, | 741 | dynamic arguments, |
722 | int id, | 742 | int id, |
743 | + Map<String, String> parameters, | ||
723 | }) { | 744 | }) { |
745 | + if (parameters != null) { | ||
746 | + final uri = Uri(path: newRouteName, queryParameters: parameters); | ||
747 | + newRouteName = uri.toString(); | ||
748 | + } | ||
749 | + | ||
724 | return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( | 750 | return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( |
725 | newRouteName, | 751 | newRouteName, |
726 | predicate ?? (_) => false, | 752 | predicate ?? (_) => false, |
@@ -95,7 +95,7 @@ void main() { | @@ -95,7 +95,7 @@ void main() { | ||
95 | await tester.pumpWidget(GetMaterialApp( | 95 | await tester.pumpWidget(GetMaterialApp( |
96 | initialRoute: '/first/juan', | 96 | initialRoute: '/first/juan', |
97 | getPages: [ | 97 | getPages: [ |
98 | - GetPage(page: () => Container(), name: '/buda'), | 98 | + GetPage(page: () => Container(), name: '/first/:name'), |
99 | GetPage(page: () => Container(), name: '/italy'), | 99 | GetPage(page: () => Container(), name: '/italy'), |
100 | ], | 100 | ], |
101 | )); | 101 | )); |
@@ -107,20 +107,13 @@ void main() { | @@ -107,20 +107,13 @@ void main() { | ||
107 | }; | 107 | }; |
108 | // print("Get.parameters: ${Get.parameters}"); | 108 | // print("Get.parameters: ${Get.parameters}"); |
109 | parameters.addAll({"a": "b", "c": "d"}); | 109 | parameters.addAll({"a": "b", "c": "d"}); |
110 | - Get.toNamed("/buda", parameters: parameters); | 110 | + Get.toNamed("/italy", parameters: parameters); |
111 | 111 | ||
112 | await tester.pumpAndSettle(); | 112 | await tester.pumpAndSettle(); |
113 | expect(Get.parameters['varginias'], 'varginia'); | 113 | expect(Get.parameters['varginias'], 'varginia'); |
114 | expect(Get.parameters['vinis'], 'viniiss'); | 114 | expect(Get.parameters['vinis'], 'viniiss'); |
115 | expect(Get.parameters['a'], 'b'); | 115 | expect(Get.parameters['a'], 'b'); |
116 | expect(Get.parameters['c'], 'd'); | 116 | expect(Get.parameters['c'], 'd'); |
117 | - | ||
118 | - Map<String, String> italyParameters; | ||
119 | - italyParameters = {"ja": "ca", "que": "i"}; | ||
120 | - Get.toNamed("/italy", parameters: italyParameters); | ||
121 | - await tester.pumpAndSettle(); | ||
122 | - expect(Get.parameters['ja'], 'ca'); | ||
123 | - expect(Get.parameters['que'], 'i'); | ||
124 | }, | 117 | }, |
125 | ); | 118 | ); |
126 | } | 119 | } |
-
Please register or login to post a comment