Jonatas

added showSnackbar as route

... ... @@ -753,6 +753,10 @@ extension GetNavigation on GetInterface {
}
}
Future<T> showSnackbar<T>(GetBar snackbar) {
return key.currentState.push(SnackRoute<T>(snack: snackbar));
}
void snackbar(
String title,
String message, {
... ...
... ... @@ -195,15 +195,10 @@ class GetBar<T extends Object> extends StatefulWidget {
/// Every other widget is ignored if this is not null.
final Form userInputForm;
SnackRoute<T> _snackRoute;
/// Show the snack. Kicks in [SnackbarStatus.OPENING] state
/// followed by [SnackbarStatus.OPEN]
Future<T> show() async {
_snackRoute = showSnack<T>(
snack: this,
) as SnackRoute<T>;
return await Get.key.currentState.push(_snackRoute);
Future<T> show<T>() async {
return Get.key.currentState.push(SnackRoute<T>(snack: this));
}
@override
... ...
... ... @@ -43,7 +43,6 @@ class SnackRoute<T> extends OverlayRoute<T> {
GetBar snack;
Builder _builder;
Future<T> get completed => _transitionCompleter.future;
final Completer<T> _transitionCompleter = Completer<T>();
SnackbarStatusCallback _snackbarStatus;
... ... @@ -164,14 +163,11 @@ class SnackRoute<T> extends OverlayRoute<T> {
/// The animation that drives the route's transition and the previous route's
/// forward transition.
Animation<Alignment> get animation => _animation;
Animation<Alignment> _animation;
/// The animation controller that the route uses to drive the transitions.
///
/// The animation itself is exposed by the [animation] property.
@protected
AnimationController get controller => _controller;
AnimationController _controller;
/// Called to create the animation controller that will drive the transitions
... ... @@ -235,7 +231,6 @@ class SnackRoute<T> extends OverlayRoute<T> {
T _result;
SnackbarStatus currentStatus;
//copy of `routes.dart`
void _handleStatusChanged(AnimationStatus status) {
switch (status) {
case AnimationStatus.completed:
... ... @@ -396,16 +391,4 @@ class SnackRoute<T> extends OverlayRoute<T> {
/// A short description of this route useful for debugging.
String get debugLabel => '$runtimeType';
@override
String toString() => '$runtimeType(animation: $_controller)';
}
SnackRoute showSnack<T>({@required GetBar snack}) {
assert(snack != null);
return SnackRoute<T>(
snack: snack,
settings: RouteSettings(name: "snackbar"),
);
}
... ...