Committed by
GitHub
Merge pull request #727 from unacorbatanegra/master
Navigation Generic && Arguments
Showing
1 changed file
with
22 additions
and
19 deletions
@@ -104,7 +104,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -104,7 +104,7 @@ extension ExtensionSnackbar on GetInterface { | ||
104 | return key?.currentState?.push(SnackRoute<T>(snack: snackbar)); | 104 | return key?.currentState?.push(SnackRoute<T>(snack: snackbar)); |
105 | } | 105 | } |
106 | 106 | ||
107 | - void snackbar( | 107 | + void snackbar<T>( |
108 | String title, | 108 | String title, |
109 | String message, { | 109 | String message, { |
110 | Color colorText, | 110 | Color colorText, |
@@ -199,11 +199,11 @@ extension ExtensionSnackbar on GetInterface { | @@ -199,11 +199,11 @@ extension ExtensionSnackbar on GetInterface { | ||
199 | userInputForm: userInputForm); | 199 | userInputForm: userInputForm); |
200 | 200 | ||
201 | if (instantInit) { | 201 | if (instantInit) { |
202 | - showSnackbar(getBar); | 202 | + showSnackbar<T>(getBar); |
203 | } else { | 203 | } else { |
204 | routing.isSnackbar = true; | 204 | routing.isSnackbar = true; |
205 | SchedulerBinding.instance.addPostFrameCallback((_) { | 205 | SchedulerBinding.instance.addPostFrameCallback((_) { |
206 | - showSnackbar(getBar); | 206 | + showSnackbar<T>(getBar); |
207 | }); | 207 | }); |
208 | } | 208 | } |
209 | } | 209 | } |
@@ -220,9 +220,11 @@ extension ExtensionDialog on GetInterface { | @@ -220,9 +220,11 @@ extension ExtensionDialog on GetInterface { | ||
220 | Color barrierColor, | 220 | Color barrierColor, |
221 | bool useSafeArea = true, | 221 | bool useSafeArea = true, |
222 | bool useRootNavigator = true, | 222 | bool useRootNavigator = true, |
223 | - RouteSettings routeSettings, | 223 | + Object arguments, |
224 | Duration transitionDuration, | 224 | Duration transitionDuration, |
225 | Curve transitionCurve, | 225 | Curve transitionCurve, |
226 | + String name, | ||
227 | + RouteSettings routeSettings, | ||
226 | }) { | 228 | }) { |
227 | assert(widget != null); | 229 | assert(widget != null); |
228 | assert(barrierDismissible != null); | 230 | assert(barrierDismissible != null); |
@@ -231,7 +233,7 @@ extension ExtensionDialog on GetInterface { | @@ -231,7 +233,7 @@ extension ExtensionDialog on GetInterface { | ||
231 | assert(debugCheckHasMaterialLocalizations(context)); | 233 | assert(debugCheckHasMaterialLocalizations(context)); |
232 | 234 | ||
233 | final theme = Theme.of(context, shadowThemeOnly: true); | 235 | final theme = Theme.of(context, shadowThemeOnly: true); |
234 | - return generalDialog( | 236 | + return generalDialog<T>( |
235 | pageBuilder: (buildContext, animation, secondaryAnimation) { | 237 | pageBuilder: (buildContext, animation, secondaryAnimation) { |
236 | final pageChild = widget; | 238 | final pageChild = widget; |
237 | Widget dialog = Builder(builder: (context) { | 239 | Widget dialog = Builder(builder: (context) { |
@@ -258,7 +260,8 @@ extension ExtensionDialog on GetInterface { | @@ -258,7 +260,8 @@ extension ExtensionDialog on GetInterface { | ||
258 | ); | 260 | ); |
259 | }, | 261 | }, |
260 | useRootNavigator: useRootNavigator, | 262 | useRootNavigator: useRootNavigator, |
261 | - routeSettings: routeSettings, | 263 | + routeSettings: |
264 | + routeSettings ?? RouteSettings(arguments: arguments, name: name), | ||
262 | ); | 265 | ); |
263 | } | 266 | } |
264 | 267 | ||
@@ -360,7 +363,7 @@ extension ExtensionDialog on GetInterface { | @@ -360,7 +363,7 @@ extension ExtensionDialog on GetInterface { | ||
360 | } | 363 | } |
361 | } | 364 | } |
362 | 365 | ||
363 | - return dialog( | 366 | + return dialog<T>( |
364 | AlertDialog( | 367 | AlertDialog( |
365 | titlePadding: EdgeInsets.all(8), | 368 | titlePadding: EdgeInsets.all(8), |
366 | contentPadding: EdgeInsets.all(8), | 369 | contentPadding: EdgeInsets.all(8), |
@@ -484,8 +487,8 @@ extension GetNavigation on GetInterface { | @@ -484,8 +487,8 @@ extension GetNavigation on GetInterface { | ||
484 | if (preventDuplicates && routeName == currentRoute) { | 487 | if (preventDuplicates && routeName == currentRoute) { |
485 | return null; | 488 | return null; |
486 | } | 489 | } |
487 | - return global(id)?.currentState?.push( | ||
488 | - GetPageRoute( | 490 | + return global(id)?.currentState?.push<T>( |
491 | + GetPageRoute<T>( | ||
489 | opaque: opaque ?? true, | 492 | opaque: opaque ?? true, |
490 | page: () => page, | 493 | page: () => page, |
491 | routeName: routeName, | 494 | routeName: routeName, |
@@ -528,7 +531,7 @@ extension GetNavigation on GetInterface { | @@ -528,7 +531,7 @@ extension GetNavigation on GetInterface { | ||
528 | if (preventDuplicates && page == currentRoute) { | 531 | if (preventDuplicates && page == currentRoute) { |
529 | return null; | 532 | return null; |
530 | } | 533 | } |
531 | - return global(id)?.currentState?.pushNamed(page, arguments: arguments); | 534 | + return global(id)?.currentState?.pushNamed<T>(page, arguments: arguments); |
532 | } | 535 | } |
533 | 536 | ||
534 | /// **Navigation.pushReplacementNamed()** shortcut.<br><br> | 537 | /// **Navigation.pushReplacementNamed()** shortcut.<br><br> |
@@ -601,7 +604,7 @@ extension GetNavigation on GetInterface { | @@ -601,7 +604,7 @@ extension GetNavigation on GetInterface { | ||
601 | Future<T> offUntil<T>(Route<T> page, RoutePredicate predicate, {int id}) { | 604 | Future<T> offUntil<T>(Route<T> page, RoutePredicate predicate, {int id}) { |
602 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate | 605 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate |
603 | // when widget don't mounted | 606 | // when widget don't mounted |
604 | - return global(id)?.currentState?.pushAndRemoveUntil(page, predicate); | 607 | + return global(id)?.currentState?.pushAndRemoveUntil<T>(page, predicate); |
605 | } | 608 | } |
606 | 609 | ||
607 | /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> | 610 | /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> |
@@ -629,7 +632,7 @@ extension GetNavigation on GetInterface { | @@ -629,7 +632,7 @@ extension GetNavigation on GetInterface { | ||
629 | }) { | 632 | }) { |
630 | return global(id) | 633 | return global(id) |
631 | ?.currentState | 634 | ?.currentState |
632 | - ?.pushNamedAndRemoveUntil(page, predicate, arguments: arguments); | 635 | + ?.pushNamedAndRemoveUntil<T>(page, predicate, arguments: arguments); |
633 | } | 636 | } |
634 | 637 | ||
635 | /// **Navigation.popAndPushNamed()** shortcut.<br><br> | 638 | /// **Navigation.popAndPushNamed()** shortcut.<br><br> |
@@ -690,7 +693,7 @@ extension GetNavigation on GetInterface { | @@ -690,7 +693,7 @@ extension GetNavigation on GetInterface { | ||
690 | dynamic arguments, | 693 | dynamic arguments, |
691 | int id, | 694 | int id, |
692 | }) { | 695 | }) { |
693 | - return global(id)?.currentState?.pushNamedAndRemoveUntil( | 696 | + return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( |
694 | newRouteName, | 697 | newRouteName, |
695 | predicate ?? (_) => false, | 698 | predicate ?? (_) => false, |
696 | arguments: arguments, | 699 | arguments: arguments, |
@@ -717,8 +720,8 @@ extension GetNavigation on GetInterface { | @@ -717,8 +720,8 @@ extension GetNavigation on GetInterface { | ||
717 | /// | 720 | /// |
718 | /// It has the advantage of not needing context, so you can call | 721 | /// It has the advantage of not needing context, so you can call |
719 | /// from your business logic. | 722 | /// from your business logic. |
720 | - void back({ | ||
721 | - dynamic result, | 723 | + void back<T>({ |
724 | + T result, | ||
722 | bool closeOverlays = false, | 725 | bool closeOverlays = false, |
723 | bool canPop = true, | 726 | bool canPop = true, |
724 | int id, | 727 | int id, |
@@ -730,10 +733,10 @@ extension GetNavigation on GetInterface { | @@ -730,10 +733,10 @@ extension GetNavigation on GetInterface { | ||
730 | } | 733 | } |
731 | if (canPop) { | 734 | if (canPop) { |
732 | if (global(id)?.currentState?.canPop() == true) { | 735 | if (global(id)?.currentState?.canPop() == true) { |
733 | - global(id)?.currentState?.pop(result); | 736 | + global(id)?.currentState?.pop<T>(result); |
734 | } | 737 | } |
735 | } else { | 738 | } else { |
736 | - global(id)?.currentState?.pop(result); | 739 | + global(id)?.currentState?.pop<T>(result); |
737 | } | 740 | } |
738 | } | 741 | } |
739 | 742 | ||
@@ -854,8 +857,8 @@ extension GetNavigation on GetInterface { | @@ -854,8 +857,8 @@ extension GetNavigation on GetInterface { | ||
854 | }) { | 857 | }) { |
855 | var routeName = "/${page.runtimeType.toString()}"; | 858 | var routeName = "/${page.runtimeType.toString()}"; |
856 | 859 | ||
857 | - return global(id)?.currentState?.pushAndRemoveUntil( | ||
858 | - GetPageRoute( | 860 | + return global(id)?.currentState?.pushAndRemoveUntil<T>( |
861 | + GetPageRoute<T>( | ||
859 | opaque: opaque ?? true, | 862 | opaque: opaque ?? true, |
860 | popGesture: popGesture ?? defaultPopGesture, | 863 | popGesture: popGesture ?? defaultPopGesture, |
861 | page: () => page, | 864 | page: () => page, |
-
Please register or login to post a comment