Jonny Borges
Committed by GitHub

Merge pull request #727 from unacorbatanegra/master

Navigation Generic && Arguments
... ... @@ -104,7 +104,7 @@ extension ExtensionSnackbar on GetInterface {
return key?.currentState?.push(SnackRoute<T>(snack: snackbar));
}
void snackbar(
void snackbar<T>(
String title,
String message, {
Color colorText,
... ... @@ -199,11 +199,11 @@ extension ExtensionSnackbar on GetInterface {
userInputForm: userInputForm);
if (instantInit) {
showSnackbar(getBar);
showSnackbar<T>(getBar);
} else {
routing.isSnackbar = true;
SchedulerBinding.instance.addPostFrameCallback((_) {
showSnackbar(getBar);
showSnackbar<T>(getBar);
});
}
}
... ... @@ -220,9 +220,11 @@ extension ExtensionDialog on GetInterface {
Color barrierColor,
bool useSafeArea = true,
bool useRootNavigator = true,
RouteSettings routeSettings,
Object arguments,
Duration transitionDuration,
Curve transitionCurve,
String name,
RouteSettings routeSettings,
}) {
assert(widget != null);
assert(barrierDismissible != null);
... ... @@ -231,7 +233,7 @@ extension ExtensionDialog on GetInterface {
assert(debugCheckHasMaterialLocalizations(context));
final theme = Theme.of(context, shadowThemeOnly: true);
return generalDialog(
return generalDialog<T>(
pageBuilder: (buildContext, animation, secondaryAnimation) {
final pageChild = widget;
Widget dialog = Builder(builder: (context) {
... ... @@ -258,7 +260,8 @@ extension ExtensionDialog on GetInterface {
);
},
useRootNavigator: useRootNavigator,
routeSettings: routeSettings,
routeSettings:
routeSettings ?? RouteSettings(arguments: arguments, name: name),
);
}
... ... @@ -360,7 +363,7 @@ extension ExtensionDialog on GetInterface {
}
}
return dialog(
return dialog<T>(
AlertDialog(
titlePadding: EdgeInsets.all(8),
contentPadding: EdgeInsets.all(8),
... ... @@ -484,8 +487,8 @@ extension GetNavigation on GetInterface {
if (preventDuplicates && routeName == currentRoute) {
return null;
}
return global(id)?.currentState?.push(
GetPageRoute(
return global(id)?.currentState?.push<T>(
GetPageRoute<T>(
opaque: opaque ?? true,
page: () => page,
routeName: routeName,
... ... @@ -528,7 +531,7 @@ extension GetNavigation on GetInterface {
if (preventDuplicates && page == currentRoute) {
return null;
}
return global(id)?.currentState?.pushNamed(page, arguments: arguments);
return global(id)?.currentState?.pushNamed<T>(page, arguments: arguments);
}
/// **Navigation.pushReplacementNamed()** shortcut.<br><br>
... ... @@ -601,7 +604,7 @@ extension GetNavigation on GetInterface {
Future<T> offUntil<T>(Route<T> page, RoutePredicate predicate, {int id}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return global(id)?.currentState?.pushAndRemoveUntil(page, predicate);
return global(id)?.currentState?.pushAndRemoveUntil<T>(page, predicate);
}
/// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br>
... ... @@ -629,7 +632,7 @@ extension GetNavigation on GetInterface {
}) {
return global(id)
?.currentState
?.pushNamedAndRemoveUntil(page, predicate, arguments: arguments);
?.pushNamedAndRemoveUntil<T>(page, predicate, arguments: arguments);
}
/// **Navigation.popAndPushNamed()** shortcut.<br><br>
... ... @@ -690,7 +693,7 @@ extension GetNavigation on GetInterface {
dynamic arguments,
int id,
}) {
return global(id)?.currentState?.pushNamedAndRemoveUntil(
return global(id)?.currentState?.pushNamedAndRemoveUntil<T>(
newRouteName,
predicate ?? (_) => false,
arguments: arguments,
... ... @@ -717,8 +720,8 @@ extension GetNavigation on GetInterface {
///
/// It has the advantage of not needing context, so you can call
/// from your business logic.
void back({
dynamic result,
void back<T>({
T result,
bool closeOverlays = false,
bool canPop = true,
int id,
... ... @@ -730,10 +733,10 @@ extension GetNavigation on GetInterface {
}
if (canPop) {
if (global(id)?.currentState?.canPop() == true) {
global(id)?.currentState?.pop(result);
global(id)?.currentState?.pop<T>(result);
}
} else {
global(id)?.currentState?.pop(result);
global(id)?.currentState?.pop<T>(result);
}
}
... ... @@ -854,8 +857,8 @@ extension GetNavigation on GetInterface {
}) {
var routeName = "/${page.runtimeType.toString()}";
return global(id)?.currentState?.pushAndRemoveUntil(
GetPageRoute(
return global(id)?.currentState?.pushAndRemoveUntil<T>(
GetPageRoute<T>(
opaque: opaque ?? true,
popGesture: popGesture ?? defaultPopGesture,
page: () => page,
... ...