Showing
15 changed files
with
249 additions
and
157 deletions
| 1 | +import 'dart:collection'; | ||
| 2 | + | ||
| 1 | import 'package:flutter/widgets.dart'; | 3 | import 'package:flutter/widgets.dart'; |
| 2 | import 'package:get/src/routes/get_route.dart'; | 4 | import 'package:get/src/routes/get_route.dart'; |
| 3 | 5 | ||
| @@ -20,7 +22,7 @@ class ParseRouteTree { | @@ -20,7 +22,7 @@ class ParseRouteTree { | ||
| 20 | // throw ("Default route was already defined"); | 22 | // throw ("Default route was already defined"); |
| 21 | // } | 23 | // } |
| 22 | var node = ParseRouteTreeNode(path, ParseRouteTreeNodeType.component); | 24 | var node = ParseRouteTreeNode(path, ParseRouteTreeNodeType.component); |
| 23 | - node.routes = [route]; | 25 | + node.routes = HashSet<GetPage>()..add(route); |
| 24 | _nodes.add(node); | 26 | _nodes.add(node); |
| 25 | // _hasDefaultRoute = true; | 27 | // _hasDefaultRoute = true; |
| 26 | return; | 28 | return; |
| @@ -45,7 +47,7 @@ class ParseRouteTree { | @@ -45,7 +47,7 @@ class ParseRouteTree { | ||
| 45 | } | 47 | } |
| 46 | if (i == pathComponents.length - 1) { | 48 | if (i == pathComponents.length - 1) { |
| 47 | if (node.routes == null) { | 49 | if (node.routes == null) { |
| 48 | - node.routes = [route]; | 50 | + node.routes = HashSet<GetPage>()..add(route); |
| 49 | } else { | 51 | } else { |
| 50 | node.routes.add(route); | 52 | node.routes.add(route); |
| 51 | } | 53 | } |
| @@ -131,8 +133,8 @@ class ParseRouteTree { | @@ -131,8 +133,8 @@ class ParseRouteTree { | ||
| 131 | if (nodeToUse != null && | 133 | if (nodeToUse != null && |
| 132 | nodeToUse.routes != null && | 134 | nodeToUse.routes != null && |
| 133 | nodeToUse.routes.length > 0) { | 135 | nodeToUse.routes.length > 0) { |
| 134 | - List<GetPage> routes = nodeToUse.routes; | ||
| 135 | - GetPageMatch routeMatch = GetPageMatch(routes[0]); | 136 | + HashSet<GetPage> routes = nodeToUse.routes; |
| 137 | + GetPageMatch routeMatch = GetPageMatch(routes.first); | ||
| 136 | 138 | ||
| 137 | routeMatch.parameters = match.parameters; | 139 | routeMatch.parameters = match.parameters; |
| 138 | 140 | ||
| @@ -201,7 +203,7 @@ class ParseRouteTreeNode { | @@ -201,7 +203,7 @@ class ParseRouteTreeNode { | ||
| 201 | 203 | ||
| 202 | String part; | 204 | String part; |
| 203 | ParseRouteTreeNodeType type; | 205 | ParseRouteTreeNodeType type; |
| 204 | - List<GetPage> routes = <GetPage>[]; | 206 | + HashSet<GetPage> routes = HashSet<GetPage>(); |
| 205 | List<ParseRouteTreeNode> nodes = <ParseRouteTreeNode>[]; | 207 | List<ParseRouteTreeNode> nodes = <ParseRouteTreeNode>[]; |
| 206 | ParseRouteTreeNode parent; | 208 | ParseRouteTreeNode parent; |
| 207 | 209 |
| @@ -43,6 +43,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -43,6 +43,7 @@ class GetMaterialApp extends StatelessWidget { | ||
| 43 | this.shortcuts, | 43 | this.shortcuts, |
| 44 | this.smartManagement = SmartManagement.full, | 44 | this.smartManagement = SmartManagement.full, |
| 45 | this.initialBinding, | 45 | this.initialBinding, |
| 46 | + this.unknownRoute, | ||
| 46 | this.routingCallback, | 47 | this.routingCallback, |
| 47 | this.defaultTransition, | 48 | this.defaultTransition, |
| 48 | // this.actions, | 49 | // this.actions, |
| @@ -106,11 +107,30 @@ class GetMaterialApp extends StatelessWidget { | @@ -106,11 +107,30 @@ class GetMaterialApp extends StatelessWidget { | ||
| 106 | final Duration transitionDuration; | 107 | final Duration transitionDuration; |
| 107 | final bool defaultGlobalState; | 108 | final bool defaultGlobalState; |
| 108 | final List<GetPage> getPages; | 109 | final List<GetPage> getPages; |
| 110 | + final GetPage unknownRoute; | ||
| 109 | 111 | ||
| 110 | Route<dynamic> generator(RouteSettings settings) { | 112 | Route<dynamic> generator(RouteSettings settings) { |
| 111 | final match = Get.routeTree.matchRoute(settings.name); | 113 | final match = Get.routeTree.matchRoute(settings.name); |
| 112 | Get.parameters = match?.parameters; | 114 | Get.parameters = match?.parameters; |
| 113 | 115 | ||
| 116 | + if (match?.route == null) { | ||
| 117 | + return GetPageRoute( | ||
| 118 | + page: unknownRoute.page, | ||
| 119 | + parameter: unknownRoute.parameter, | ||
| 120 | + settings: | ||
| 121 | + RouteSettings(name: settings.name, arguments: settings.arguments), | ||
| 122 | + curve: unknownRoute.curve, | ||
| 123 | + opaque: unknownRoute.opaque, | ||
| 124 | + customTransition: match.route.customTransition, | ||
| 125 | + binding: unknownRoute.binding, | ||
| 126 | + bindings: unknownRoute.bindings, | ||
| 127 | + duration: (transitionDuration ?? unknownRoute.transitionDuration), | ||
| 128 | + transition: unknownRoute.transition, | ||
| 129 | + popGesture: unknownRoute.popGesture, | ||
| 130 | + fullscreenDialog: unknownRoute.fullscreenDialog, | ||
| 131 | + ); | ||
| 132 | + } | ||
| 133 | + | ||
| 114 | return GetPageRoute( | 134 | return GetPageRoute( |
| 115 | page: match.route.page, | 135 | page: match.route.page, |
| 116 | parameter: match.route.parameter, | 136 | parameter: match.route.parameter, |
| @@ -118,6 +138,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -118,6 +138,7 @@ class GetMaterialApp extends StatelessWidget { | ||
| 118 | RouteSettings(name: settings.name, arguments: settings.arguments), | 138 | RouteSettings(name: settings.name, arguments: settings.arguments), |
| 119 | curve: match.route.curve, | 139 | curve: match.route.curve, |
| 120 | opaque: match.route.opaque, | 140 | opaque: match.route.opaque, |
| 141 | + customTransition: match.route.customTransition, | ||
| 121 | binding: match.route.binding, | 142 | binding: match.route.binding, |
| 122 | bindings: match.route.bindings, | 143 | bindings: match.route.bindings, |
| 123 | duration: (transitionDuration ?? match.route.transitionDuration), | 144 | duration: (transitionDuration ?? match.route.transitionDuration), |
| @@ -3,6 +3,8 @@ import 'package:flutter/widgets.dart'; | @@ -3,6 +3,8 @@ import 'package:flutter/widgets.dart'; | ||
| 3 | abstract class CustomTransition { | 3 | abstract class CustomTransition { |
| 4 | Widget buildTransition( | 4 | Widget buildTransition( |
| 5 | BuildContext context, | 5 | BuildContext context, |
| 6 | + Curve curve, | ||
| 7 | + Alignment alignment, | ||
| 6 | Animation<double> animation, | 8 | Animation<double> animation, |
| 7 | Animation<double> secondaryAnimation, | 9 | Animation<double> secondaryAnimation, |
| 8 | Widget child, | 10 | Widget child, |
| @@ -16,6 +16,7 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -16,6 +16,7 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
| 16 | final bool popGesture; | 16 | final bool popGesture; |
| 17 | final Transition transition; | 17 | final Transition transition; |
| 18 | final Curve curve; | 18 | final Curve curve; |
| 19 | + final Alignment alignment; | ||
| 19 | final GetPageBuilder page; | 20 | final GetPageBuilder page; |
| 20 | final CustomTransition customTransition; | 21 | final CustomTransition customTransition; |
| 21 | final Bindings binding; | 22 | final Bindings binding; |
| @@ -32,8 +33,9 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -32,8 +33,9 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
| 32 | this.bindings, | 33 | this.bindings, |
| 33 | this.opaque = true, | 34 | this.opaque = true, |
| 34 | this.parameter, | 35 | this.parameter, |
| 36 | + this.alignment, | ||
| 35 | this.fullscreenDialog = false, | 37 | this.fullscreenDialog = false, |
| 36 | - this.curve, | 38 | + this.curve = Curves.linear, |
| 37 | this.popGesture, | 39 | this.popGesture, |
| 38 | this.customTransition, | 40 | this.customTransition, |
| 39 | }) : super( | 41 | }) : super( |
| @@ -64,6 +66,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -64,6 +66,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
| 64 | if (this.customTransition != null) { | 66 | if (this.customTransition != null) { |
| 65 | return this.customTransition.buildTransition( | 67 | return this.customTransition.buildTransition( |
| 66 | context, | 68 | context, |
| 69 | + curve, | ||
| 70 | + alignment, | ||
| 67 | animation, | 71 | animation, |
| 68 | secondaryAnimation, | 72 | secondaryAnimation, |
| 69 | popGesture ?? Get.defaultPopGesture | 73 | popGesture ?? Get.defaultPopGesture |
| @@ -82,6 +86,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -82,6 +86,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
| 82 | if (Get.customTransition != null) { | 86 | if (Get.customTransition != null) { |
| 83 | return Get.customTransition.buildTransition( | 87 | return Get.customTransition.buildTransition( |
| 84 | context, | 88 | context, |
| 89 | + curve, | ||
| 90 | + alignment, | ||
| 85 | animation, | 91 | animation, |
| 86 | secondaryAnimation, | 92 | secondaryAnimation, |
| 87 | popGesture ?? Get.defaultPopGesture | 93 | popGesture ?? Get.defaultPopGesture |
| @@ -96,6 +102,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -96,6 +102,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
| 96 | return TransitionFilter.newTransitionComponent(Get.defaultTransition) | 102 | return TransitionFilter.newTransitionComponent(Get.defaultTransition) |
| 97 | .buildChildWithTransition( | 103 | .buildChildWithTransition( |
| 98 | context, | 104 | context, |
| 105 | + curve, | ||
| 106 | + alignment, | ||
| 99 | curvedAnimation, | 107 | curvedAnimation, |
| 100 | secondaryAnimation, | 108 | secondaryAnimation, |
| 101 | popGesture ?? Get.defaultPopGesture | 109 | popGesture ?? Get.defaultPopGesture |
| @@ -122,6 +130,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -122,6 +130,8 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
| 122 | return TransitionFilter.newTransitionComponent(transition) | 130 | return TransitionFilter.newTransitionComponent(transition) |
| 123 | .buildChildWithTransition( | 131 | .buildChildWithTransition( |
| 124 | context, | 132 | context, |
| 133 | + curve, | ||
| 134 | + alignment, | ||
| 125 | curvedAnimation, | 135 | curvedAnimation, |
| 126 | secondaryAnimation, | 136 | secondaryAnimation, |
| 127 | popGesture ?? Get.defaultPopGesture | 137 | popGesture ?? Get.defaultPopGesture |
| @@ -134,7 +144,7 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | @@ -134,7 +144,7 @@ class GetPageRoute<T> extends PageRouteBuilder<T> { | ||
| 134 | 144 | ||
| 135 | @override | 145 | @override |
| 136 | Duration get transitionDuration => | 146 | Duration get transitionDuration => |
| 137 | - this.duration ?? Duration(milliseconds: 300); | 147 | + this.duration ?? Duration(milliseconds: 400); |
| 138 | 148 | ||
| 139 | static bool _isPopGestureEnabled<T>(PageRoute<T> route) { | 149 | static bool _isPopGestureEnabled<T>(PageRoute<T> route) { |
| 140 | if (route.isFirst) return false; | 150 | if (route.isFirst) return false; |
| @@ -10,6 +10,8 @@ class LeftToRightFadeTransition extends TransitionInterface { | @@ -10,6 +10,8 @@ class LeftToRightFadeTransition extends TransitionInterface { | ||
| 10 | @override | 10 | @override |
| 11 | Widget buildChildWithTransition( | 11 | Widget buildChildWithTransition( |
| 12 | BuildContext context, | 12 | BuildContext context, |
| 13 | + Curve curve, | ||
| 14 | + Alignment alignment, | ||
| 13 | Animation<double> animation, | 15 | Animation<double> animation, |
| 14 | Animation<double> secondaryAnimation, | 16 | Animation<double> secondaryAnimation, |
| 15 | Widget child) { | 17 | Widget child) { |
| @@ -39,6 +41,8 @@ class RightToLeftFadeTransition extends TransitionInterface { | @@ -39,6 +41,8 @@ class RightToLeftFadeTransition extends TransitionInterface { | ||
| 39 | @override | 41 | @override |
| 40 | Widget buildChildWithTransition( | 42 | Widget buildChildWithTransition( |
| 41 | BuildContext context, | 43 | BuildContext context, |
| 44 | + Curve curve, | ||
| 45 | + Alignment alignment, | ||
| 42 | Animation<double> animation, | 46 | Animation<double> animation, |
| 43 | Animation<double> secondaryAnimation, | 47 | Animation<double> secondaryAnimation, |
| 44 | Widget child) { | 48 | Widget child) { |
| @@ -68,11 +72,13 @@ class NoTransition extends TransitionInterface { | @@ -68,11 +72,13 @@ class NoTransition extends TransitionInterface { | ||
| 68 | @override | 72 | @override |
| 69 | Widget buildChildWithTransition( | 73 | Widget buildChildWithTransition( |
| 70 | BuildContext context, | 74 | BuildContext context, |
| 75 | + Curve curve, | ||
| 76 | + Alignment alignment, | ||
| 71 | Animation<double> animation, | 77 | Animation<double> animation, |
| 72 | Animation<double> secondaryAnimation, | 78 | Animation<double> secondaryAnimation, |
| 73 | Widget child) { | 79 | Widget child) { |
| 74 | return transitionComponent.buildChildWithTransition( | 80 | return transitionComponent.buildChildWithTransition( |
| 75 | - context, animation, secondaryAnimation, child); | 81 | + context, curve, alignment, animation, secondaryAnimation, child); |
| 76 | } | 82 | } |
| 77 | } | 83 | } |
| 78 | 84 | ||
| @@ -84,13 +90,15 @@ class FadeInTransition extends TransitionInterface { | @@ -84,13 +90,15 @@ class FadeInTransition extends TransitionInterface { | ||
| 84 | @override | 90 | @override |
| 85 | Widget buildChildWithTransition( | 91 | Widget buildChildWithTransition( |
| 86 | BuildContext context, | 92 | BuildContext context, |
| 93 | + Curve curve, | ||
| 94 | + Alignment alignment, | ||
| 87 | Animation<double> animation, | 95 | Animation<double> animation, |
| 88 | Animation<double> secondaryAnimation, | 96 | Animation<double> secondaryAnimation, |
| 89 | Widget child) { | 97 | Widget child) { |
| 90 | return FadeTransition( | 98 | return FadeTransition( |
| 91 | opacity: animation, | 99 | opacity: animation, |
| 92 | child: transitionComponent.buildChildWithTransition( | 100 | child: transitionComponent.buildChildWithTransition( |
| 93 | - context, animation, secondaryAnimation, child), | 101 | + context, curve, alignment, animation, secondaryAnimation, child), |
| 94 | ); | 102 | ); |
| 95 | } | 103 | } |
| 96 | } | 104 | } |
| @@ -103,6 +111,8 @@ class SlideDownTransition extends TransitionInterface { | @@ -103,6 +111,8 @@ class SlideDownTransition extends TransitionInterface { | ||
| 103 | @override | 111 | @override |
| 104 | Widget buildChildWithTransition( | 112 | Widget buildChildWithTransition( |
| 105 | BuildContext context, | 113 | BuildContext context, |
| 114 | + Curve curve, | ||
| 115 | + Alignment alignment, | ||
| 106 | Animation<double> animation, | 116 | Animation<double> animation, |
| 107 | Animation<double> secondaryAnimation, | 117 | Animation<double> secondaryAnimation, |
| 108 | Widget child) { | 118 | Widget child) { |
| @@ -112,7 +122,7 @@ class SlideDownTransition extends TransitionInterface { | @@ -112,7 +122,7 @@ class SlideDownTransition extends TransitionInterface { | ||
| 112 | end: Offset.zero, | 122 | end: Offset.zero, |
| 113 | ).animate(animation), | 123 | ).animate(animation), |
| 114 | child: transitionComponent.buildChildWithTransition( | 124 | child: transitionComponent.buildChildWithTransition( |
| 115 | - context, animation, secondaryAnimation, child), | 125 | + context, curve, alignment, animation, secondaryAnimation, child), |
| 116 | ); | 126 | ); |
| 117 | } | 127 | } |
| 118 | } | 128 | } |
| @@ -125,6 +135,8 @@ class SlideLeftTransition extends TransitionInterface { | @@ -125,6 +135,8 @@ class SlideLeftTransition extends TransitionInterface { | ||
| 125 | @override | 135 | @override |
| 126 | Widget buildChildWithTransition( | 136 | Widget buildChildWithTransition( |
| 127 | BuildContext context, | 137 | BuildContext context, |
| 138 | + Curve curve, | ||
| 139 | + Alignment alignment, | ||
| 128 | Animation<double> animation, | 140 | Animation<double> animation, |
| 129 | Animation<double> secondaryAnimation, | 141 | Animation<double> secondaryAnimation, |
| 130 | Widget child) { | 142 | Widget child) { |
| @@ -134,7 +146,7 @@ class SlideLeftTransition extends TransitionInterface { | @@ -134,7 +146,7 @@ class SlideLeftTransition extends TransitionInterface { | ||
| 134 | end: Offset.zero, | 146 | end: Offset.zero, |
| 135 | ).animate(animation), | 147 | ).animate(animation), |
| 136 | child: transitionComponent.buildChildWithTransition( | 148 | child: transitionComponent.buildChildWithTransition( |
| 137 | - context, animation, secondaryAnimation, child), | 149 | + context, curve, alignment, animation, secondaryAnimation, child), |
| 138 | ); | 150 | ); |
| 139 | } | 151 | } |
| 140 | } | 152 | } |
| @@ -147,6 +159,8 @@ class SlideRightTransition extends TransitionInterface { | @@ -147,6 +159,8 @@ class SlideRightTransition extends TransitionInterface { | ||
| 147 | @override | 159 | @override |
| 148 | Widget buildChildWithTransition( | 160 | Widget buildChildWithTransition( |
| 149 | BuildContext context, | 161 | BuildContext context, |
| 162 | + Curve curve, | ||
| 163 | + Alignment alignment, | ||
| 150 | Animation<double> animation, | 164 | Animation<double> animation, |
| 151 | Animation<double> secondaryAnimation, | 165 | Animation<double> secondaryAnimation, |
| 152 | Widget child) { | 166 | Widget child) { |
| @@ -156,7 +170,7 @@ class SlideRightTransition extends TransitionInterface { | @@ -156,7 +170,7 @@ class SlideRightTransition extends TransitionInterface { | ||
| 156 | end: Offset.zero, | 170 | end: Offset.zero, |
| 157 | ).animate(animation), | 171 | ).animate(animation), |
| 158 | child: transitionComponent.buildChildWithTransition( | 172 | child: transitionComponent.buildChildWithTransition( |
| 159 | - context, animation, secondaryAnimation, child), | 173 | + context, curve, alignment, animation, secondaryAnimation, child), |
| 160 | ); | 174 | ); |
| 161 | } | 175 | } |
| 162 | } | 176 | } |
| @@ -169,6 +183,8 @@ class SlideTopTransition extends TransitionInterface { | @@ -169,6 +183,8 @@ class SlideTopTransition extends TransitionInterface { | ||
| 169 | @override | 183 | @override |
| 170 | Widget buildChildWithTransition( | 184 | Widget buildChildWithTransition( |
| 171 | BuildContext context, | 185 | BuildContext context, |
| 186 | + Curve curve, | ||
| 187 | + Alignment alignment, | ||
| 172 | Animation<double> animation, | 188 | Animation<double> animation, |
| 173 | Animation<double> secondaryAnimation, | 189 | Animation<double> secondaryAnimation, |
| 174 | Widget child) { | 190 | Widget child) { |
| @@ -178,7 +194,7 @@ class SlideTopTransition extends TransitionInterface { | @@ -178,7 +194,7 @@ class SlideTopTransition extends TransitionInterface { | ||
| 178 | end: Offset.zero, | 194 | end: Offset.zero, |
| 179 | ).animate(animation), | 195 | ).animate(animation), |
| 180 | child: transitionComponent.buildChildWithTransition( | 196 | child: transitionComponent.buildChildWithTransition( |
| 181 | - context, animation, secondaryAnimation, child), | 197 | + context, curve, alignment, animation, secondaryAnimation, child), |
| 182 | ); | 198 | ); |
| 183 | } | 199 | } |
| 184 | } | 200 | } |
| @@ -191,13 +207,63 @@ class ZoomInTransition extends TransitionInterface { | @@ -191,13 +207,63 @@ class ZoomInTransition extends TransitionInterface { | ||
| 191 | @override | 207 | @override |
| 192 | Widget buildChildWithTransition( | 208 | Widget buildChildWithTransition( |
| 193 | BuildContext context, | 209 | BuildContext context, |
| 210 | + Curve curve, | ||
| 211 | + Alignment alignment, | ||
| 194 | Animation<double> animation, | 212 | Animation<double> animation, |
| 195 | Animation<double> secondaryAnimation, | 213 | Animation<double> secondaryAnimation, |
| 196 | Widget child) { | 214 | Widget child) { |
| 197 | return ScaleTransition( | 215 | return ScaleTransition( |
| 198 | scale: animation, | 216 | scale: animation, |
| 199 | child: transitionComponent.buildChildWithTransition( | 217 | child: transitionComponent.buildChildWithTransition( |
| 200 | - context, animation, secondaryAnimation, child), | 218 | + context, curve, alignment, animation, secondaryAnimation, child), |
| 219 | + ); | ||
| 220 | + } | ||
| 221 | +} | ||
| 222 | + | ||
| 223 | +class SizeTransitions extends TransitionInterface { | ||
| 224 | + SizeTransitions({ | ||
| 225 | + TransitionComponent transitionComponent, | ||
| 226 | + }) : super(transitionComponent: transitionComponent); | ||
| 227 | + | ||
| 228 | + @override | ||
| 229 | + Widget buildChildWithTransition( | ||
| 230 | + BuildContext context, | ||
| 231 | + Curve curve, | ||
| 232 | + Alignment alignment, | ||
| 233 | + Animation<double> animation, | ||
| 234 | + Animation<double> secondaryAnimation, | ||
| 235 | + Widget child) { | ||
| 236 | + return Align( | ||
| 237 | + alignment: Alignment.center, | ||
| 238 | + child: SizeTransition( | ||
| 239 | + sizeFactor: CurvedAnimation( | ||
| 240 | + parent: animation, | ||
| 241 | + curve: curve, | ||
| 242 | + ), | ||
| 243 | + child: child, | ||
| 244 | + ), | ||
| 245 | + ); | ||
| 246 | + } | ||
| 247 | +} | ||
| 248 | + | ||
| 249 | +class CupertinoTransitions extends TransitionInterface { | ||
| 250 | + CupertinoTransitions({ | ||
| 251 | + TransitionComponent transitionComponent, | ||
| 252 | + }) : super(transitionComponent: transitionComponent); | ||
| 253 | + | ||
| 254 | + @override | ||
| 255 | + Widget buildChildWithTransition( | ||
| 256 | + BuildContext context, | ||
| 257 | + Curve curve, | ||
| 258 | + Alignment alignment, | ||
| 259 | + Animation<double> animation, | ||
| 260 | + Animation<double> secondaryAnimation, | ||
| 261 | + Widget child) { | ||
| 262 | + return CupertinoPageTransition( | ||
| 263 | + primaryRouteAnimation: animation, | ||
| 264 | + secondaryRouteAnimation: secondaryAnimation, | ||
| 265 | + linearTransition: true, | ||
| 266 | + child: child, | ||
| 201 | ); | 267 | ); |
| 202 | } | 268 | } |
| 203 | } | 269 | } |
| 1 | import 'package:flutter/widgets.dart'; | 1 | import 'package:flutter/widgets.dart'; |
| 2 | import 'package:get/src/routes/bindings_interface.dart'; | 2 | import 'package:get/src/routes/bindings_interface.dart'; |
| 3 | +import 'custom_transition.dart'; | ||
| 3 | import 'transitions_type.dart'; | 4 | import 'transitions_type.dart'; |
| 4 | 5 | ||
| 5 | class GetPage { | 6 | class GetPage { |
| @@ -15,7 +16,7 @@ class GetPage { | @@ -15,7 +16,7 @@ class GetPage { | ||
| 15 | final bool opaque; | 16 | final bool opaque; |
| 16 | final Bindings binding; | 17 | final Bindings binding; |
| 17 | final List<Bindings> bindings; | 18 | final List<Bindings> bindings; |
| 18 | - final Widget customTransition; | 19 | + final CustomTransition customTransition; |
| 19 | final Duration transitionDuration; | 20 | final Duration transitionDuration; |
| 20 | final bool fullscreenDialog; | 21 | final bool fullscreenDialog; |
| 21 | final RouteSettings settings; | 22 | final RouteSettings settings; |
| @@ -3,6 +3,8 @@ import 'package:flutter/widgets.dart'; | @@ -3,6 +3,8 @@ import 'package:flutter/widgets.dart'; | ||
| 3 | class TransitionComponent { | 3 | class TransitionComponent { |
| 4 | Widget buildChildWithTransition( | 4 | Widget buildChildWithTransition( |
| 5 | BuildContext context, | 5 | BuildContext context, |
| 6 | + Curve curve, | ||
| 7 | + Alignment alignment, | ||
| 6 | Animation<double> animation, | 8 | Animation<double> animation, |
| 7 | Animation<double> secondaryAnimation, | 9 | Animation<double> secondaryAnimation, |
| 8 | Widget child) { | 10 | Widget child) { |
| @@ -33,6 +33,13 @@ class TransitionFilter { | @@ -33,6 +33,13 @@ class TransitionFilter { | ||
| 33 | case Transition.leftToRightWithFade: | 33 | case Transition.leftToRightWithFade: |
| 34 | return LeftToRightFadeTransition( | 34 | return LeftToRightFadeTransition( |
| 35 | transitionComponent: transitionComponent); | 35 | transitionComponent: transitionComponent); |
| 36 | + | ||
| 37 | + case Transition.cupertino: | ||
| 38 | + return CupertinoTransitions(transitionComponent: transitionComponent); | ||
| 39 | + | ||
| 40 | + case Transition.size: | ||
| 41 | + return SizeTransitions(transitionComponent: transitionComponent); | ||
| 42 | + | ||
| 36 | default: | 43 | default: |
| 37 | return FadeInTransition(transitionComponent: transitionComponent); | 44 | return FadeInTransition(transitionComponent: transitionComponent); |
| 38 | } | 45 | } |
| @@ -3,7 +3,7 @@ import 'dart:ui'; | @@ -3,7 +3,7 @@ import 'dart:ui'; | ||
| 3 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 4 | import 'package:flutter/scheduler.dart'; | 4 | import 'package:flutter/scheduler.dart'; |
| 5 | import 'package:get/get.dart'; | 5 | import 'package:get/get.dart'; |
| 6 | -import 'snack_route.dart' as route; | 6 | +import 'snack_route.dart' as snackroute; |
| 7 | 7 | ||
| 8 | typedef void SnackStatusCallback(SnackStatus status); | 8 | typedef void SnackStatusCallback(SnackStatus status); |
| 9 | typedef void OnTap(GetBar snack); | 9 | typedef void OnTap(GetBar snack); |
| @@ -209,11 +209,11 @@ class GetBar<T extends Object> extends StatefulWidget { | @@ -209,11 +209,11 @@ class GetBar<T extends Object> extends StatefulWidget { | ||
| 209 | /// A [TextFormField] in case you want a simple user input. Every other widget is ignored if this is not null. | 209 | /// A [TextFormField] in case you want a simple user input. Every other widget is ignored if this is not null. |
| 210 | final Form userInputForm; | 210 | final Form userInputForm; |
| 211 | 211 | ||
| 212 | - route.SnackRoute<T> _snackRoute; | 212 | + snackroute.SnackRoute<T> _snackRoute; |
| 213 | 213 | ||
| 214 | /// Show the snack. Kicks in [SnackStatus.IS_APPEARING] state followed by [SnackStatus.SHOWING] | 214 | /// Show the snack. Kicks in [SnackStatus.IS_APPEARING] state followed by [SnackStatus.SHOWING] |
| 215 | Future<T> show() async { | 215 | Future<T> show() async { |
| 216 | - _snackRoute = route.showSnack<T>( | 216 | + _snackRoute = snackroute.showSnack<T>( |
| 217 | snack: this, | 217 | snack: this, |
| 218 | ) as SnackRoute<T>; | 218 | ) as SnackRoute<T>; |
| 219 | return await Get.key.currentState.push(_snackRoute); | 219 | return await Get.key.currentState.push(_snackRoute); |
| 1 | import 'dart:async'; | 1 | import 'dart:async'; |
| 2 | import 'dart:ui'; | 2 | import 'dart:ui'; |
| 3 | -import 'snack.dart'; | ||
| 4 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 5 | -import 'package:flutter/scheduler.dart'; | 4 | +import 'package:get/src/snackbar/snack.dart'; |
| 6 | 5 | ||
| 7 | class SnackRoute<T> extends OverlayRoute<T> { | 6 | class SnackRoute<T> extends OverlayRoute<T> { |
| 8 | - Animation<double> _filterBlurAnimation; | ||
| 9 | - Animation<Color> _filterColorAnimation; | 7 | + final GetBar snack; |
| 8 | + final Builder _builder; | ||
| 9 | + final Completer<T> _transitionCompleter = Completer<T>(); | ||
| 10 | + final SnackStatusCallback _onStatusChanged; | ||
| 11 | + Alignment _initialAlignment; | ||
| 12 | + Alignment _endAlignment; | ||
| 13 | + bool _wasDismissedBySwipe = false; | ||
| 14 | + Timer _timer; | ||
| 15 | + T _result; | ||
| 16 | + SnackStatus currentStatus; | ||
| 10 | 17 | ||
| 11 | SnackRoute({ | 18 | SnackRoute({ |
| 12 | @required this.snack, | 19 | @required this.snack, |
| 13 | RouteSettings settings, | 20 | RouteSettings settings, |
| 14 | - }) : super(settings: settings) { | ||
| 15 | - this._builder = Builder(builder: (BuildContext innerContext) { | 21 | + }) : _builder = Builder(builder: (BuildContext innerContext) { |
| 16 | return GestureDetector( | 22 | return GestureDetector( |
| 17 | child: snack, | 23 | child: snack, |
| 18 | - onTap: snack.onTap != null | ||
| 19 | - ? () { | ||
| 20 | - snack.onTap(snack); | ||
| 21 | - } | ||
| 22 | - : null, | 24 | + onTap: snack.onTap != null ? () => snack.onTap(snack) : null, |
| 23 | ); | 25 | ); |
| 24 | - }); | ||
| 25 | - | 26 | + }), |
| 27 | + _onStatusChanged = snack.onStatusChanged, | ||
| 28 | + super(settings: settings) { | ||
| 26 | _configureAlignment(this.snack.snackPosition); | 29 | _configureAlignment(this.snack.snackPosition); |
| 27 | - _onStatusChanged = snack.onStatusChanged; | ||
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | - _configureAlignment(SnackPosition snackPosition) { | 32 | + void _configureAlignment(SnackPosition snackPosition) { |
| 31 | switch (snack.snackPosition) { | 33 | switch (snack.snackPosition) { |
| 32 | case SnackPosition.TOP: | 34 | case SnackPosition.TOP: |
| 33 | { | 35 | { |
| @@ -44,51 +46,12 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -44,51 +46,12 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 44 | } | 46 | } |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | - GetBar snack; | ||
| 48 | - Builder _builder; | ||
| 49 | - | ||
| 50 | Future<T> get completed => _transitionCompleter.future; | 49 | Future<T> get completed => _transitionCompleter.future; |
| 51 | - final Completer<T> _transitionCompleter = Completer<T>(); | ||
| 52 | - | ||
| 53 | - SnackStatusCallback _onStatusChanged; | ||
| 54 | - Alignment _initialAlignment; | ||
| 55 | - Alignment _endAlignment; | ||
| 56 | - bool _wasDismissedBySwipe = false; | ||
| 57 | - | ||
| 58 | - Timer _timer; | ||
| 59 | - | ||
| 60 | bool get opaque => false; | 50 | bool get opaque => false; |
| 61 | 51 | ||
| 62 | @override | 52 | @override |
| 63 | Iterable<OverlayEntry> createOverlayEntries() { | 53 | Iterable<OverlayEntry> createOverlayEntries() { |
| 64 | - List<OverlayEntry> overlays = []; | ||
| 65 | - | ||
| 66 | - if (snack.overlayBlur > 0.0) { | ||
| 67 | - overlays.add( | ||
| 68 | - OverlayEntry( | ||
| 69 | - builder: (BuildContext context) { | ||
| 70 | - return GestureDetector( | ||
| 71 | - onTap: snack.isDismissible ? () => snack.dismiss() : null, | ||
| 72 | - child: AnimatedBuilder( | ||
| 73 | - animation: _filterBlurAnimation, | ||
| 74 | - builder: (context, child) { | ||
| 75 | - return BackdropFilter( | ||
| 76 | - filter: ImageFilter.blur( | ||
| 77 | - sigmaX: _filterBlurAnimation.value, | ||
| 78 | - sigmaY: _filterBlurAnimation.value), | ||
| 79 | - child: Container( | ||
| 80 | - constraints: BoxConstraints.expand(), | ||
| 81 | - color: _filterColorAnimation.value, | ||
| 82 | - ), | ||
| 83 | - ); | ||
| 84 | - }, | ||
| 85 | - ), | ||
| 86 | - ); | ||
| 87 | - }, | ||
| 88 | - maintainState: false, | ||
| 89 | - opaque: opaque), | ||
| 90 | - ); | ||
| 91 | - } | 54 | + final List<OverlayEntry> overlays = []; |
| 92 | 55 | ||
| 93 | overlays.add( | 56 | overlays.add( |
| 94 | OverlayEntry( | 57 | OverlayEntry( |
| @@ -96,9 +59,7 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -96,9 +59,7 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 96 | final Widget annotatedChild = Semantics( | 59 | final Widget annotatedChild = Semantics( |
| 97 | child: AlignTransition( | 60 | child: AlignTransition( |
| 98 | alignment: _animation, | 61 | alignment: _animation, |
| 99 | - child: snack.isDismissible | ||
| 100 | - ? _getDismissibleSnack(_builder) | ||
| 101 | - : _getSnack(), | 62 | + child: _getSnack(), |
| 102 | ), | 63 | ), |
| 103 | focused: false, | 64 | focused: false, |
| 104 | container: true, | 65 | container: true, |
| @@ -116,33 +77,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -116,33 +77,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 116 | /// This string is a workaround until Dismissible supports a returning item | 77 | /// This string is a workaround until Dismissible supports a returning item |
| 117 | String dismissibleKeyGen = ""; | 78 | String dismissibleKeyGen = ""; |
| 118 | 79 | ||
| 119 | - Widget _getDismissibleSnack(Widget child) { | ||
| 120 | - return Dismissible( | ||
| 121 | - direction: _getDismissDirection(), | ||
| 122 | - resizeDuration: null, | ||
| 123 | - confirmDismiss: (_) { | ||
| 124 | - if (currentStatus == SnackStatus.IS_APPEARING || | ||
| 125 | - currentStatus == SnackStatus.IS_HIDING) { | ||
| 126 | - return Future.value(false); | ||
| 127 | - } | ||
| 128 | - return Future.value(true); | ||
| 129 | - }, | ||
| 130 | - key: Key(dismissibleKeyGen), | ||
| 131 | - onDismissed: (_) { | ||
| 132 | - dismissibleKeyGen += "1"; | ||
| 133 | - _cancelTimer(); | ||
| 134 | - _wasDismissedBySwipe = true; | ||
| 135 | - | ||
| 136 | - if (isCurrent) { | ||
| 137 | - navigator.pop(); | ||
| 138 | - } else { | ||
| 139 | - navigator.removeRoute(this); | ||
| 140 | - } | ||
| 141 | - }, | ||
| 142 | - child: _getSnack(), | ||
| 143 | - ); | ||
| 144 | - } | ||
| 145 | - | ||
| 146 | Widget _getSnack() { | 80 | Widget _getSnack() { |
| 147 | return Container( | 81 | return Container( |
| 148 | margin: snack.margin, | 82 | margin: snack.margin, |
| @@ -150,18 +84,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -150,18 +84,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 150 | ); | 84 | ); |
| 151 | } | 85 | } |
| 152 | 86 | ||
| 153 | - DismissDirection _getDismissDirection() { | ||
| 154 | - if (snack.dismissDirection == SnackDismissDirection.HORIZONTAL) { | ||
| 155 | - return DismissDirection.horizontal; | ||
| 156 | - } else { | ||
| 157 | - if (snack.snackPosition == SnackPosition.TOP) { | ||
| 158 | - return DismissDirection.up; | ||
| 159 | - } else { | ||
| 160 | - return DismissDirection.down; | ||
| 161 | - } | ||
| 162 | - } | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | @override | 87 | @override |
| 166 | bool get finishedWhenPopped => | 88 | bool get finishedWhenPopped => |
| 167 | _controller.status == AnimationStatus.dismissed; | 89 | _controller.status == AnimationStatus.dismissed; |
| @@ -210,6 +132,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -210,6 +132,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 210 | } | 132 | } |
| 211 | 133 | ||
| 212 | Animation<double> createBlurFilterAnimation() { | 134 | Animation<double> createBlurFilterAnimation() { |
| 135 | + if (snack.overlayBlur == null) return null; | ||
| 136 | + | ||
| 213 | return Tween(begin: 0.0, end: snack.overlayBlur).animate( | 137 | return Tween(begin: 0.0, end: snack.overlayBlur).animate( |
| 214 | CurvedAnimation( | 138 | CurvedAnimation( |
| 215 | parent: _controller, | 139 | parent: _controller, |
| @@ -223,6 +147,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -223,6 +147,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 223 | } | 147 | } |
| 224 | 148 | ||
| 225 | Animation<Color> createColorFilterAnimation() { | 149 | Animation<Color> createColorFilterAnimation() { |
| 150 | + if (snack.overlayColor == null) return null; | ||
| 151 | + | ||
| 226 | return ColorTween(begin: Colors.transparent, end: snack.overlayColor) | 152 | return ColorTween(begin: Colors.transparent, end: snack.overlayColor) |
| 227 | .animate( | 153 | .animate( |
| 228 | CurvedAnimation( | 154 | CurvedAnimation( |
| @@ -236,9 +162,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -236,9 +162,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 236 | ); | 162 | ); |
| 237 | } | 163 | } |
| 238 | 164 | ||
| 239 | - T _result; | ||
| 240 | - SnackStatus currentStatus; | ||
| 241 | - | ||
| 242 | //copy of `routes.dart` | 165 | //copy of `routes.dart` |
| 243 | void _handleStatusChanged(AnimationStatus status) { | 166 | void _handleStatusChanged(AnimationStatus status) { |
| 244 | switch (status) { | 167 | switch (status) { |
| @@ -282,8 +205,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -282,8 +205,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 282 | _controller = createAnimationController(); | 205 | _controller = createAnimationController(); |
| 283 | assert(_controller != null, | 206 | assert(_controller != null, |
| 284 | '$runtimeType.createAnimationController() returned null.'); | 207 | '$runtimeType.createAnimationController() returned null.'); |
| 285 | - _filterBlurAnimation = createBlurFilterAnimation(); | ||
| 286 | - _filterColorAnimation = createColorFilterAnimation(); | ||
| 287 | _animation = createAnimation(); | 208 | _animation = createAnimation(); |
| 288 | assert(_animation != null, '$runtimeType.createAnimation() returned null.'); | 209 | assert(_animation != null, '$runtimeType.createAnimation() returned null.'); |
| 289 | super.install(); | 210 | super.install(); |
| @@ -291,28 +212,17 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -291,28 +212,17 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 291 | 212 | ||
| 292 | @override | 213 | @override |
| 293 | TickerFuture didPush() { | 214 | TickerFuture didPush() { |
| 294 | - super.didPush(); | ||
| 295 | assert(_controller != null, | 215 | assert(_controller != null, |
| 296 | '$runtimeType.didPush called before calling install() or after calling dispose().'); | 216 | '$runtimeType.didPush called before calling install() or after calling dispose().'); |
| 297 | assert(!_transitionCompleter.isCompleted, | 217 | assert(!_transitionCompleter.isCompleted, |
| 298 | 'Cannot reuse a $runtimeType after disposing it.'); | 218 | 'Cannot reuse a $runtimeType after disposing it.'); |
| 299 | _animation.addStatusListener(_handleStatusChanged); | 219 | _animation.addStatusListener(_handleStatusChanged); |
| 300 | _configureTimer(); | 220 | _configureTimer(); |
| 221 | + super.didPush(); | ||
| 301 | return _controller.forward(); | 222 | return _controller.forward(); |
| 302 | } | 223 | } |
| 303 | 224 | ||
| 304 | @override | 225 | @override |
| 305 | - void didReplace(Route<dynamic> oldRoute) { | ||
| 306 | - assert(_controller != null, | ||
| 307 | - '$runtimeType.didReplace called before calling install() or after calling dispose().'); | ||
| 308 | - assert(!_transitionCompleter.isCompleted, | ||
| 309 | - 'Cannot reuse a $runtimeType after disposing it.'); | ||
| 310 | - if (oldRoute is SnackRoute) _controller.value = oldRoute._controller.value; | ||
| 311 | - _animation.addStatusListener(_handleStatusChanged); | ||
| 312 | - super.didReplace(oldRoute); | ||
| 313 | - } | ||
| 314 | - | ||
| 315 | - @override | ||
| 316 | bool didPop(T result) { | 226 | bool didPop(T result) { |
| 317 | assert(_controller != null, | 227 | assert(_controller != null, |
| 318 | '$runtimeType.didPop called before calling install() or after calling dispose().'); | 228 | '$runtimeType.didPop called before calling install() or after calling dispose().'); |
| @@ -360,17 +270,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -360,17 +270,6 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 360 | } | 270 | } |
| 361 | } | 271 | } |
| 362 | 272 | ||
| 363 | - /// Whether this route can perform a transition to the given route. | ||
| 364 | - /// Subclasses can override this method to restrict the set of routes they | ||
| 365 | - /// need to coordinate transitions with. | ||
| 366 | - bool canTransitionTo(SnackRoute<dynamic> nextRoute) => true; | ||
| 367 | - | ||
| 368 | - /// Whether this route can perform a transition from the given route. | ||
| 369 | - /// | ||
| 370 | - /// Subclasses can override this method to restrict the set of routes they | ||
| 371 | - /// need to coordinate transitions with. | ||
| 372 | - bool canTransitionFrom(SnackRoute<dynamic> previousRoute) => true; | ||
| 373 | - | ||
| 374 | @override | 273 | @override |
| 375 | void dispose() { | 274 | void dispose() { |
| 376 | assert(!_transitionCompleter.isCompleted, | 275 | assert(!_transitionCompleter.isCompleted, |
| @@ -388,10 +287,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -388,10 +287,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 388 | } | 287 | } |
| 389 | 288 | ||
| 390 | SnackRoute showSnack<T>({@required GetBar snack}) { | 289 | SnackRoute showSnack<T>({@required GetBar snack}) { |
| 391 | - assert(snack != null); | ||
| 392 | - | ||
| 393 | return SnackRoute<T>( | 290 | return SnackRoute<T>( |
| 394 | snack: snack, | 291 | snack: snack, |
| 395 | - settings: RouteSettings(name: "snackbar"), | 292 | + settings: RouteSettings(name: 'snackbar'), |
| 396 | ); | 293 | ); |
| 397 | } | 294 | } |
| 1 | name: get | 1 | name: get |
| 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get. |
| 3 | -version: 3.1.2 | 3 | +version: 3.1.3 |
| 4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
| @@ -4,6 +4,28 @@ import 'package:get/get.dart'; | @@ -4,6 +4,28 @@ import 'package:get/get.dart'; | ||
| 4 | 4 | ||
| 5 | import 'util/wrapper.dart'; | 5 | import 'util/wrapper.dart'; |
| 6 | 6 | ||
| 7 | +class SizeTransitions extends CustomTransition { | ||
| 8 | + @override | ||
| 9 | + Widget buildTransition( | ||
| 10 | + BuildContext context, | ||
| 11 | + Curve curve, | ||
| 12 | + Alignment alignment, | ||
| 13 | + Animation<double> animation, | ||
| 14 | + Animation<double> secondaryAnimation, | ||
| 15 | + Widget child) { | ||
| 16 | + return Align( | ||
| 17 | + alignment: Alignment.center, | ||
| 18 | + child: SizeTransition( | ||
| 19 | + sizeFactor: CurvedAnimation( | ||
| 20 | + parent: animation, | ||
| 21 | + curve: curve, | ||
| 22 | + ), | ||
| 23 | + child: child, | ||
| 24 | + ), | ||
| 25 | + ); | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 7 | void main() { | 29 | void main() { |
| 8 | testWidgets("Get.to smoke test", (tester) async { | 30 | testWidgets("Get.to smoke test", (tester) async { |
| 9 | await tester.pumpWidget( | 31 | await tester.pumpWidget( |
| @@ -21,7 +43,10 @@ void main() { | @@ -21,7 +43,10 @@ void main() { | ||
| 21 | GetMaterialApp( | 43 | GetMaterialApp( |
| 22 | initialRoute: '/', | 44 | initialRoute: '/', |
| 23 | getPages: [ | 45 | getPages: [ |
| 24 | - GetPage(page: () => FirstScreen(), name: '/'), | 46 | + GetPage( |
| 47 | + page: () => FirstScreen(), | ||
| 48 | + name: '/', | ||
| 49 | + customTransition: SizeTransitions()), | ||
| 25 | GetPage(page: () => SecondScreen(), name: '/second'), | 50 | GetPage(page: () => SecondScreen(), name: '/second'), |
| 26 | GetPage(page: () => ThirdScreen(), name: '/third'), | 51 | GetPage(page: () => ThirdScreen(), name: '/third'), |
| 27 | ], | 52 | ], |
| @@ -188,9 +213,17 @@ void main() { | @@ -188,9 +213,17 @@ void main() { | ||
| 188 | WrapperNamed( | 213 | WrapperNamed( |
| 189 | initialRoute: '/', | 214 | initialRoute: '/', |
| 190 | namedRoutes: [ | 215 | namedRoutes: [ |
| 191 | - GetPage(page: () => Container(), name: '/'), | ||
| 192 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
| 193 | - GetPage(page: () => SecondScreen(), name: '/second'), | 216 | + GetPage( |
| 217 | + page: () => Container(), | ||
| 218 | + name: '/', | ||
| 219 | + popGesture: true, | ||
| 220 | + transition: Transition.cupertino), | ||
| 221 | + GetPage( | ||
| 222 | + page: () => FirstScreen(), | ||
| 223 | + name: '/first', | ||
| 224 | + transition: Transition.size), | ||
| 225 | + GetPage( | ||
| 226 | + page: () => SecondScreen(), name: '/second', transition: null), | ||
| 194 | GetPage(page: () => ThirdScreen(), name: '/third'), | 227 | GetPage(page: () => ThirdScreen(), name: '/third'), |
| 195 | ], | 228 | ], |
| 196 | ), | 229 | ), |
| @@ -324,16 +357,42 @@ void main() { | @@ -324,16 +357,42 @@ void main() { | ||
| 324 | await tester.pumpAndSettle(); | 357 | await tester.pumpAndSettle(); |
| 325 | 358 | ||
| 326 | expect(find.byType(FirstScreen), findsOneWidget); | 359 | expect(find.byType(FirstScreen), findsOneWidget); |
| 360 | + | ||
| 361 | + await tester.pumpWidget( | ||
| 362 | + Wrapper( | ||
| 363 | + child: Container(), | ||
| 364 | + defaultTransition: Transition.cupertino, | ||
| 365 | + ), | ||
| 366 | + ); | ||
| 367 | + | ||
| 368 | + Get.to(FirstScreen()); | ||
| 369 | + | ||
| 370 | + await tester.pumpAndSettle(); | ||
| 371 | + | ||
| 372 | + expect(find.byType(FirstScreen), findsOneWidget); | ||
| 373 | + | ||
| 374 | + await tester.pumpWidget( | ||
| 375 | + Wrapper( | ||
| 376 | + child: Container(), | ||
| 377 | + defaultTransition: Transition.size, | ||
| 378 | + ), | ||
| 379 | + ); | ||
| 380 | + | ||
| 381 | + Get.to(FirstScreen()); | ||
| 382 | + | ||
| 383 | + await tester.pumpAndSettle(); | ||
| 384 | + | ||
| 385 | + expect(find.byType(FirstScreen), findsOneWidget); | ||
| 327 | }); | 386 | }); |
| 328 | 387 | ||
| 329 | testWidgets("Get.snackbar test", (tester) async { | 388 | testWidgets("Get.snackbar test", (tester) async { |
| 330 | await tester.pumpWidget( | 389 | await tester.pumpWidget( |
| 331 | - Wrapper( | ||
| 332 | - child: RaisedButton( | 390 | + GetMaterialApp( |
| 391 | + popGesture: true, | ||
| 392 | + home: RaisedButton( | ||
| 333 | child: Text('Open Snackbar'), | 393 | child: Text('Open Snackbar'), |
| 334 | onPressed: () { | 394 | onPressed: () { |
| 335 | - Get.snackbar('title', "message", | ||
| 336 | - duration: Duration(seconds: 1), instantInit: true); | 395 | + Get.snackbar('title', "message", duration: Duration(seconds: 1)); |
| 337 | }, | 396 | }, |
| 338 | ), | 397 | ), |
| 339 | ), | 398 | ), |
| @@ -355,8 +414,18 @@ void main() { | @@ -355,8 +414,18 @@ void main() { | ||
| 355 | Get.rawSnackbar( | 414 | Get.rawSnackbar( |
| 356 | title: 'title', | 415 | title: 'title', |
| 357 | message: "message", | 416 | message: "message", |
| 417 | + onTap: (_) { | ||
| 418 | + print('snackbar tapped'); | ||
| 419 | + }, | ||
| 358 | duration: Duration(seconds: 1), | 420 | duration: Duration(seconds: 1), |
| 359 | - instantInit: true); | 421 | + shouldIconPulse: true, |
| 422 | + icon: Icon(Icons.alarm), | ||
| 423 | + showProgressIndicator: true, | ||
| 424 | + barBlur: null, | ||
| 425 | + isDismissible: true, | ||
| 426 | + leftBarIndicatorColor: Colors.amber, | ||
| 427 | + overlayBlur: 1.0, | ||
| 428 | + ); | ||
| 360 | }, | 429 | }, |
| 361 | ), | 430 | ), |
| 362 | ), | 431 | ), |
| @@ -14,6 +14,15 @@ void main() { | @@ -14,6 +14,15 @@ void main() { | ||
| 14 | "GetRoute maintainState null", | 14 | "GetRoute maintainState null", |
| 15 | (WidgetTester testr) async { | 15 | (WidgetTester testr) async { |
| 16 | expect( | 16 | expect( |
| 17 | + () => GetPage(page: () => Scaffold(), maintainState: null, name: '/'), | ||
| 18 | + throwsAssertionError); | ||
| 19 | + }, | ||
| 20 | + ); | ||
| 21 | + | ||
| 22 | + testWidgets( | ||
| 23 | + "GetRoute name null", | ||
| 24 | + (WidgetTester testr) async { | ||
| 25 | + expect( | ||
| 17 | () => | 26 | () => |
| 18 | GetPage(page: () => Scaffold(), maintainState: null, name: null), | 27 | GetPage(page: () => Scaffold(), maintainState: null, name: null), |
| 19 | throwsAssertionError); | 28 | throwsAssertionError); |
| @@ -25,7 +34,7 @@ void main() { | @@ -25,7 +34,7 @@ void main() { | ||
| 25 | (WidgetTester testr) async { | 34 | (WidgetTester testr) async { |
| 26 | expect( | 35 | expect( |
| 27 | () => GetPage( | 36 | () => GetPage( |
| 28 | - page: () => Scaffold(), fullscreenDialog: null, name: null), | 37 | + page: () => Scaffold(), fullscreenDialog: null, name: '/'), |
| 29 | throwsAssertionError); | 38 | throwsAssertionError); |
| 30 | }, | 39 | }, |
| 31 | ); | 40 | ); |
-
Please register or login to post a comment