Jonatas

added showSnackbar as route

@@ -753,6 +753,10 @@ extension GetNavigation on GetInterface { @@ -753,6 +753,10 @@ extension GetNavigation on GetInterface {
753 } 753 }
754 } 754 }
755 755
  756 + Future<T> showSnackbar<T>(GetBar snackbar) {
  757 + return key.currentState.push(SnackRoute<T>(snack: snackbar));
  758 + }
  759 +
756 void snackbar( 760 void snackbar(
757 String title, 761 String title,
758 String message, { 762 String message, {
@@ -195,15 +195,10 @@ class GetBar<T extends Object> extends StatefulWidget { @@ -195,15 +195,10 @@ class GetBar<T extends Object> extends StatefulWidget {
195 /// Every other widget is ignored if this is not null. 195 /// Every other widget is ignored if this is not null.
196 final Form userInputForm; 196 final Form userInputForm;
197 197
198 - SnackRoute<T> _snackRoute;  
199 -  
200 /// Show the snack. Kicks in [SnackbarStatus.OPENING] state 198 /// Show the snack. Kicks in [SnackbarStatus.OPENING] state
201 /// followed by [SnackbarStatus.OPEN] 199 /// followed by [SnackbarStatus.OPEN]
202 - Future<T> show() async {  
203 - _snackRoute = showSnack<T>(  
204 - snack: this,  
205 - ) as SnackRoute<T>;  
206 - return await Get.key.currentState.push(_snackRoute); 200 + Future<T> show<T>() async {
  201 + return Get.key.currentState.push(SnackRoute<T>(snack: this));
207 } 202 }
208 203
209 @override 204 @override
@@ -43,7 +43,6 @@ class SnackRoute<T> extends OverlayRoute<T> { @@ -43,7 +43,6 @@ class SnackRoute<T> extends OverlayRoute<T> {
43 GetBar snack; 43 GetBar snack;
44 Builder _builder; 44 Builder _builder;
45 45
46 - Future<T> get completed => _transitionCompleter.future;  
47 final Completer<T> _transitionCompleter = Completer<T>(); 46 final Completer<T> _transitionCompleter = Completer<T>();
48 47
49 SnackbarStatusCallback _snackbarStatus; 48 SnackbarStatusCallback _snackbarStatus;
@@ -164,14 +163,11 @@ class SnackRoute<T> extends OverlayRoute<T> { @@ -164,14 +163,11 @@ class SnackRoute<T> extends OverlayRoute<T> {
164 163
165 /// The animation that drives the route's transition and the previous route's 164 /// The animation that drives the route's transition and the previous route's
166 /// forward transition. 165 /// forward transition.
167 - Animation<Alignment> get animation => _animation;  
168 Animation<Alignment> _animation; 166 Animation<Alignment> _animation;
169 167
170 /// The animation controller that the route uses to drive the transitions. 168 /// The animation controller that the route uses to drive the transitions.
171 /// 169 ///
172 /// The animation itself is exposed by the [animation] property. 170 /// The animation itself is exposed by the [animation] property.
173 - @protected  
174 - AnimationController get controller => _controller;  
175 AnimationController _controller; 171 AnimationController _controller;
176 172
177 /// Called to create the animation controller that will drive the transitions 173 /// Called to create the animation controller that will drive the transitions
@@ -235,7 +231,6 @@ class SnackRoute<T> extends OverlayRoute<T> { @@ -235,7 +231,6 @@ class SnackRoute<T> extends OverlayRoute<T> {
235 T _result; 231 T _result;
236 SnackbarStatus currentStatus; 232 SnackbarStatus currentStatus;
237 233
238 - //copy of `routes.dart`  
239 void _handleStatusChanged(AnimationStatus status) { 234 void _handleStatusChanged(AnimationStatus status) {
240 switch (status) { 235 switch (status) {
241 case AnimationStatus.completed: 236 case AnimationStatus.completed:
@@ -396,16 +391,4 @@ class SnackRoute<T> extends OverlayRoute<T> { @@ -396,16 +391,4 @@ class SnackRoute<T> extends OverlayRoute<T> {
396 391
397 /// A short description of this route useful for debugging. 392 /// A short description of this route useful for debugging.
398 String get debugLabel => '$runtimeType'; 393 String get debugLabel => '$runtimeType';
399 -  
400 - @override  
401 - String toString() => '$runtimeType(animation: $_controller)';  
402 -}  
403 -  
404 -SnackRoute showSnack<T>({@required GetBar snack}) {  
405 - assert(snack != null);  
406 -  
407 - return SnackRoute<T>(  
408 - snack: snack,  
409 - settings: RouteSettings(name: "snackbar"),  
410 - );  
411 } 394 }