Showing
24 changed files
with
355 additions
and
536 deletions
@@ -153,6 +153,26 @@ | @@ -153,6 +153,26 @@ | ||
153 | ## [1.11.1] | 153 | ## [1.11.1] |
154 | -Improve swipe to back on iOS devices | 154 | -Improve swipe to back on iOS devices |
155 | 155 | ||
156 | - ## [1.12.0-dev] | ||
157 | - -Compatibility with Dev branch | 156 | +## [1.11.2] |
157 | + -Fix flutter web platform and added GetPlatform | ||
158 | + | ||
159 | +## [1.11.3] | ||
160 | +-Added docs | ||
161 | + | ||
162 | +## [1.11.4] | ||
163 | +- Refactor code of library | ||
164 | + | ||
165 | +## [1.12.0-dev] | ||
166 | +-Compatibility with Dev branch | ||
167 | + | ||
168 | +## [1.13.0-dev] | ||
169 | +- Plugin refactor | ||
170 | +- Added GetPlatform | ||
171 | + | ||
172 | +## [1.13.1-dev] | ||
173 | +- Fix back function | ||
174 | + | ||
175 | + | ||
176 | + | ||
177 | + | ||
158 | 178 |
@@ -11,7 +11,7 @@ increasing your productivity, and eliminating all the bugs present in Flutter's | @@ -11,7 +11,7 @@ increasing your productivity, and eliminating all the bugs present in Flutter's | ||
11 | 11 | ||
12 | ##### If you use MODULAR, add on your MaterialApp this: navigatorKey: Get.addKey(Modular.navigatorKey) | 12 | ##### If you use MODULAR, add on your MaterialApp this: navigatorKey: Get.addKey(Modular.navigatorKey) |
13 | 13 | ||
14 | -##### If you use master/dev branch of Flutter, use the version 1.12.0-dev. | 14 | +##### If you use master/dev branch of Flutter, use the version 1.12.1-dev. |
15 | 15 | ||
16 | ## How to use? | 16 | ## How to use? |
17 | 17 | ||
@@ -19,7 +19,7 @@ Add this to your package's pubspec.yaml file: | @@ -19,7 +19,7 @@ Add this to your package's pubspec.yaml file: | ||
19 | 19 | ||
20 | ``` | 20 | ``` |
21 | dependencies: | 21 | dependencies: |
22 | - get: ^1.11.1 // get: ^1.12.0-dev on dev/master | 22 | + get: ^1.11.6 // get: ^1.13.1-dev on dev/master |
23 | ``` | 23 | ``` |
24 | 24 | ||
25 | And import it: | 25 | And import it: |
@@ -249,8 +249,6 @@ class MiddleWare { | @@ -249,8 +249,6 @@ class MiddleWare { | ||
249 | } | 249 | } |
250 | ``` | 250 | ``` |
251 | 251 | ||
252 | - | ||
253 | - | ||
254 | ### COPY THE ROUTER CLASS BELOW: | 252 | ### COPY THE ROUTER CLASS BELOW: |
255 | Copy this Router class below and put it in your app, rename routes and classes for your own, add more classes to it if necessary. | 253 | Copy this Router class below and put it in your app, rename routes and classes for your own, add more classes to it if necessary. |
256 | 254 | ||
@@ -283,35 +281,7 @@ class Router { | @@ -283,35 +281,7 @@ class Router { | ||
283 | } | 281 | } |
284 | } | 282 | } |
285 | ``` | 283 | ``` |
286 | -##### Experimental | ||
287 | -If you need specific Cupertino elements, such as dragging to close, you can use GetCupertino: | ||
288 | -```dart | ||
289 | -class Router { | ||
290 | - static Route<dynamic> generateRoute(RouteSettings settings) { | ||
291 | - switch (settings.name) { | ||
292 | - case '/': | ||
293 | - return GetCupertino( | ||
294 | - page: First(), | ||
295 | - settings: settings, | ||
296 | - ); | ||
297 | - case '/second': | ||
298 | - return GetCupertino( | ||
299 | - settings: settings, page: Second()); | ||
300 | - case '/third': | ||
301 | - return GetCupertino( | ||
302 | - settings: settings, | ||
303 | - page: Third()); | ||
304 | - default: | ||
305 | - return GetCupertino( | ||
306 | - settings: settings, | ||
307 | - page: Scaffold( | ||
308 | - body: | ||
309 | - Center(child: Text('No route defined for ${settings.name}')), | ||
310 | - )); | ||
311 | - } | ||
312 | - } | ||
313 | -} | ||
314 | -``` | 284 | + |
315 | And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (BLoC will love it), and when your app is compiled to the web, your routes will appear in the url beautifully <3 | 285 | And now, all you need to do is use Get.toNamed() to navigate your named routes, without any context (BLoC will love it), and when your app is compiled to the web, your routes will appear in the url beautifully <3 |
316 | 286 | ||
317 | ```dart | 287 | ```dart |
@@ -395,6 +365,14 @@ Get.until() // back repeatedly until the predicate returns true. | @@ -395,6 +365,14 @@ Get.until() // back repeatedly until the predicate returns true. | ||
395 | Get.offUntil() // go to next route and remove all the previous routes until the predicate returns true. | 365 | Get.offUntil() // go to next route and remove all the previous routes until the predicate returns true. |
396 | 366 | ||
397 | Get.offNamedUntil() // go to next named route and remove all the previous routes until the predicate returns true. | 367 | Get.offNamedUntil() // go to next named route and remove all the previous routes until the predicate returns true. |
368 | + | ||
369 | +GetPlatform.isAndroid/isIOS/isWeb... //(This method is completely compatible with FlutterWeb, unlike the framework. "Platform.isAndroid") | ||
370 | + | ||
371 | +Get.height / Get.width // Equivalent to the method: MediaQuery.of(context).size.height | ||
372 | + | ||
373 | +Get.context // Gives the context of the screen in the foreground anywhere in your code. | ||
374 | + | ||
375 | +var arguments = Get.args(context); // Gives current route arguments | ||
398 | ``` | 376 | ``` |
399 | 377 | ||
400 | -That is all. | 378 | +This library will always be updated and implementing new features. Feel free to offer PRs and contribute to them. |
example/.dart_tool/package_config.json
0 → 100644
1 | +{ | ||
2 | + "configVersion": 2, | ||
3 | + "packages": [ | ||
4 | + { | ||
5 | + "name": "archive", | ||
6 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/archive-2.0.11", | ||
7 | + "packageUri": "lib/", | ||
8 | + "languageVersion": "2.0" | ||
9 | + }, | ||
10 | + { | ||
11 | + "name": "args", | ||
12 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.5.2", | ||
13 | + "packageUri": "lib/", | ||
14 | + "languageVersion": "2.0" | ||
15 | + }, | ||
16 | + { | ||
17 | + "name": "async", | ||
18 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.4.0", | ||
19 | + "packageUri": "lib/", | ||
20 | + "languageVersion": "2.0" | ||
21 | + }, | ||
22 | + { | ||
23 | + "name": "boolean_selector", | ||
24 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.5", | ||
25 | + "packageUri": "lib/", | ||
26 | + "languageVersion": "2.0" | ||
27 | + }, | ||
28 | + { | ||
29 | + "name": "charcode", | ||
30 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2", | ||
31 | + "packageUri": "lib/", | ||
32 | + "languageVersion": "1.0" | ||
33 | + }, | ||
34 | + { | ||
35 | + "name": "collection", | ||
36 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11", | ||
37 | + "packageUri": "lib/", | ||
38 | + "languageVersion": "2.0" | ||
39 | + }, | ||
40 | + { | ||
41 | + "name": "convert", | ||
42 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1", | ||
43 | + "packageUri": "lib/", | ||
44 | + "languageVersion": "1.17" | ||
45 | + }, | ||
46 | + { | ||
47 | + "name": "crypto", | ||
48 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.3", | ||
49 | + "packageUri": "lib/", | ||
50 | + "languageVersion": "2.1" | ||
51 | + }, | ||
52 | + { | ||
53 | + "name": "cupertino_icons", | ||
54 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.3", | ||
55 | + "packageUri": "lib/", | ||
56 | + "languageVersion": "2.0" | ||
57 | + }, | ||
58 | + { | ||
59 | + "name": "flutter", | ||
60 | + "rootUri": "file:///opt/flutter/packages/flutter", | ||
61 | + "packageUri": "lib/", | ||
62 | + "languageVersion": "2.2" | ||
63 | + }, | ||
64 | + { | ||
65 | + "name": "flutter_test", | ||
66 | + "rootUri": "file:///opt/flutter/packages/flutter_test", | ||
67 | + "packageUri": "lib/", | ||
68 | + "languageVersion": "2.2" | ||
69 | + }, | ||
70 | + { | ||
71 | + "name": "get", | ||
72 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.11.6", | ||
73 | + "packageUri": "lib/", | ||
74 | + "languageVersion": "2.1" | ||
75 | + }, | ||
76 | + { | ||
77 | + "name": "image", | ||
78 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.4", | ||
79 | + "packageUri": "lib/", | ||
80 | + "languageVersion": "2.0" | ||
81 | + }, | ||
82 | + { | ||
83 | + "name": "matcher", | ||
84 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.6", | ||
85 | + "packageUri": "lib/", | ||
86 | + "languageVersion": "2.2" | ||
87 | + }, | ||
88 | + { | ||
89 | + "name": "meta", | ||
90 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8", | ||
91 | + "packageUri": "lib/", | ||
92 | + "languageVersion": "1.12" | ||
93 | + }, | ||
94 | + { | ||
95 | + "name": "path", | ||
96 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.4", | ||
97 | + "packageUri": "lib/", | ||
98 | + "languageVersion": "2.0" | ||
99 | + }, | ||
100 | + { | ||
101 | + "name": "petitparser", | ||
102 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/petitparser-2.4.0", | ||
103 | + "packageUri": "lib/", | ||
104 | + "languageVersion": "2.4" | ||
105 | + }, | ||
106 | + { | ||
107 | + "name": "quiver", | ||
108 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.5", | ||
109 | + "packageUri": "lib/", | ||
110 | + "languageVersion": "2.0" | ||
111 | + }, | ||
112 | + { | ||
113 | + "name": "sky_engine", | ||
114 | + "rootUri": "file:///opt/flutter/bin/cache/pkg/sky_engine", | ||
115 | + "packageUri": "lib/", | ||
116 | + "languageVersion": "1.11" | ||
117 | + }, | ||
118 | + { | ||
119 | + "name": "source_span", | ||
120 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5", | ||
121 | + "packageUri": "lib/", | ||
122 | + "languageVersion": "1.8" | ||
123 | + }, | ||
124 | + { | ||
125 | + "name": "stack_trace", | ||
126 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3", | ||
127 | + "packageUri": "lib/", | ||
128 | + "languageVersion": "1.23" | ||
129 | + }, | ||
130 | + { | ||
131 | + "name": "stream_channel", | ||
132 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0", | ||
133 | + "packageUri": "lib/", | ||
134 | + "languageVersion": "2.0" | ||
135 | + }, | ||
136 | + { | ||
137 | + "name": "string_scanner", | ||
138 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5", | ||
139 | + "packageUri": "lib/", | ||
140 | + "languageVersion": "2.0" | ||
141 | + }, | ||
142 | + { | ||
143 | + "name": "term_glyph", | ||
144 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0", | ||
145 | + "packageUri": "lib/", | ||
146 | + "languageVersion": "1.8" | ||
147 | + }, | ||
148 | + { | ||
149 | + "name": "test_api", | ||
150 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.15", | ||
151 | + "packageUri": "lib/", | ||
152 | + "languageVersion": "2.4" | ||
153 | + }, | ||
154 | + { | ||
155 | + "name": "typed_data", | ||
156 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6", | ||
157 | + "packageUri": "lib/", | ||
158 | + "languageVersion": "2.0" | ||
159 | + }, | ||
160 | + { | ||
161 | + "name": "vector_math", | ||
162 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8", | ||
163 | + "packageUri": "lib/", | ||
164 | + "languageVersion": "2.0" | ||
165 | + }, | ||
166 | + { | ||
167 | + "name": "xml", | ||
168 | + "rootUri": "file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/xml-3.5.0", | ||
169 | + "packageUri": "lib/", | ||
170 | + "languageVersion": "2.3" | ||
171 | + }, | ||
172 | + { | ||
173 | + "name": "profileweb", | ||
174 | + "rootUri": "../", | ||
175 | + "packageUri": "lib/", | ||
176 | + "languageVersion": "2.1" | ||
177 | + } | ||
178 | + ], | ||
179 | + "generated": "2020-03-30T23:54:30.607116Z", | ||
180 | + "generator": "pub", | ||
181 | + "generatorVersion": "2.8.0-dev.17.0.flutter-1402e8e1a4" | ||
182 | +} |
example/.packages
0 → 100644
1 | +# Generated by pub on 2020-03-30 20:54:30.579731. | ||
2 | +archive:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/archive-2.0.11/lib/ | ||
3 | +args:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.5.2/lib/ | ||
4 | +async:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.4.0/lib/ | ||
5 | +boolean_selector:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.5/lib/ | ||
6 | +charcode:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/ | ||
7 | +collection:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/ | ||
8 | +convert:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1/lib/ | ||
9 | +crypto:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.3/lib/ | ||
10 | +cupertino_icons:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.3/lib/ | ||
11 | +flutter:file:///opt/flutter/packages/flutter/lib/ | ||
12 | +flutter_test:file:///opt/flutter/packages/flutter_test/lib/ | ||
13 | +get:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.11.6/lib/ | ||
14 | +image:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.4/lib/ | ||
15 | +matcher:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.6/lib/ | ||
16 | +meta:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8/lib/ | ||
17 | +path:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.4/lib/ | ||
18 | +petitparser:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/petitparser-2.4.0/lib/ | ||
19 | +quiver:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.5/lib/ | ||
20 | +sky_engine:file:///opt/flutter/bin/cache/pkg/sky_engine/lib/ | ||
21 | +source_span:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/ | ||
22 | +stack_trace:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/ | ||
23 | +stream_channel:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib/ | ||
24 | +string_scanner:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/ | ||
25 | +term_glyph:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/ | ||
26 | +test_api:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.15/lib/ | ||
27 | +typed_data:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/ | ||
28 | +vector_math:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/ | ||
29 | +xml:file:///opt/flutter/.pub-cache/hosted/pub.dartlang.org/xml-3.5.0/lib/ | ||
30 | +profileweb:lib/ |
@@ -80,7 +80,7 @@ packages: | @@ -80,7 +80,7 @@ packages: | ||
80 | name: get | 80 | name: get |
81 | url: "https://pub.dartlang.org" | 81 | url: "https://pub.dartlang.org" |
82 | source: hosted | 82 | source: hosted |
83 | - version: "1.10.0" | 83 | + version: "1.11.6" |
84 | image: | 84 | image: |
85 | dependency: transitive | 85 | dependency: transitive |
86 | description: | 86 | description: |
@@ -109,13 +109,6 @@ packages: | @@ -109,13 +109,6 @@ packages: | ||
109 | url: "https://pub.dartlang.org" | 109 | url: "https://pub.dartlang.org" |
110 | source: hosted | 110 | source: hosted |
111 | version: "1.6.4" | 111 | version: "1.6.4" |
112 | - pedantic: | ||
113 | - dependency: transitive | ||
114 | - description: | ||
115 | - name: pedantic | ||
116 | - url: "https://pub.dartlang.org" | ||
117 | - source: hosted | ||
118 | - version: "1.8.0+1" | ||
119 | petitparser: | 112 | petitparser: |
120 | dependency: transitive | 113 | dependency: transitive |
121 | description: | 114 | description: |
@@ -176,7 +169,7 @@ packages: | @@ -176,7 +169,7 @@ packages: | ||
176 | name: test_api | 169 | name: test_api |
177 | url: "https://pub.dartlang.org" | 170 | url: "https://pub.dartlang.org" |
178 | source: hosted | 171 | source: hosted |
179 | - version: "0.2.11" | 172 | + version: "0.2.15" |
180 | typed_data: | 173 | typed_data: |
181 | dependency: transitive | 174 | dependency: transitive |
182 | description: | 175 | description: |
1 | library get; | 1 | library get; |
2 | 2 | ||
3 | -export 'src/getroute.dart'; | ||
4 | -export 'src/routes.dart'; | ||
5 | -export 'src/snack.dart'; | ||
6 | -export 'src/bottomsheet.dart'; | ||
7 | -export 'src/snack_route.dart'; | ||
8 | -export 'src/route_observer.dart'; | ||
9 | -export 'src/getroute_cupertino.dart'; | ||
10 | -export 'src/transitions_type.dart'; | 3 | +export 'src/routes/default_route.dart'; |
4 | +export 'src/get_main.dart'; | ||
5 | +export 'src/snackbar/snack.dart'; | ||
6 | +export 'src/bottomsheet/bottomsheet.dart'; | ||
7 | +export 'src/snackbar/snack_route.dart'; | ||
8 | +export 'src/routes/observers/route_observer.dart'; | ||
9 | +export 'src/routes/transitions_type.dart'; | ||
10 | +export 'src/platform/platform.dart'; |
@@ -4,6 +4,7 @@ import 'package:get/src/dialog/dialog.dart'; | @@ -4,6 +4,7 @@ import 'package:get/src/dialog/dialog.dart'; | ||
4 | import 'package:get/get.dart'; | 4 | import 'package:get/get.dart'; |
5 | import 'routes/blur/backdrop_blur.dart'; | 5 | import 'routes/blur/backdrop_blur.dart'; |
6 | import 'routes/blur/transparent_route.dart'; | 6 | import 'routes/blur/transparent_route.dart'; |
7 | +import 'routes/default_route.dart'; | ||
7 | 8 | ||
8 | class Get { | 9 | class Get { |
9 | static Get _get; | 10 | static Get _get; |
@@ -44,23 +45,14 @@ class Get { | @@ -44,23 +45,14 @@ class Get { | ||
44 | /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior | 45 | /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior |
45 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. | 46 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. |
46 | static Future<T> to<T>(Widget page, | 47 | static Future<T> to<T>(Widget page, |
47 | - {bool rebuildRoutes, | ||
48 | - Transition transition, | ||
49 | - Duration duration = const Duration(milliseconds: 400)}) { | 48 | + {bool rebuildRoutes, Transition transition, Duration duration}) { |
50 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate | 49 | // if (key.currentState.mounted) // add this if appear problems on future with route navigate |
51 | // when widget don't mounted | 50 | // when widget don't mounted |
52 | - | ||
53 | - return GetPlatform.isIOS | ||
54 | - ? key.currentState.push(GetCupertino( | ||
55 | - opaque: rebuildRoutes ?? true, | ||
56 | - page: page, | ||
57 | - transition: transition ?? Transition.cupertino, | ||
58 | - duration: duration)) | ||
59 | - : key.currentState.push(GetRoute( | ||
60 | - opaque: rebuildRoutes ?? false, | ||
61 | - page: page, | ||
62 | - transition: transition ?? Transition.fade, | ||
63 | - duration: duration)); | 51 | + return key.currentState.push(GetRoute( |
52 | + rebuildRoutes: rebuildRoutes, | ||
53 | + page: page, | ||
54 | + transition: transition ?? Transition.cupertino, | ||
55 | + duration: duration ?? const Duration(milliseconds: 400))); | ||
64 | } | 56 | } |
65 | 57 | ||
66 | /// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed | 58 | /// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed |
@@ -118,7 +110,7 @@ class Get { | @@ -118,7 +110,7 @@ class Get { | ||
118 | } | 110 | } |
119 | 111 | ||
120 | /// It replaces Navigator.pop, but needs no context. | 112 | /// It replaces Navigator.pop, but needs no context. |
121 | - static void back({dynamic result}) { | 113 | + static back({dynamic result}) { |
122 | return key.currentState.pop(result); | 114 | return key.currentState.pop(result); |
123 | } | 115 | } |
124 | 116 | ||
@@ -128,7 +120,7 @@ class Get { | @@ -128,7 +120,7 @@ class Get { | ||
128 | times = 1; | 120 | times = 1; |
129 | } | 121 | } |
130 | int count = 0; | 122 | int count = 0; |
131 | - var back = key.currentState.popUntil((route) { | 123 | + void back = key.currentState.popUntil((route) { |
132 | return count++ == times; | 124 | return count++ == times; |
133 | }); | 125 | }); |
134 | return back; | 126 | return back; |
@@ -142,11 +134,9 @@ class Get { | @@ -142,11 +134,9 @@ class Get { | ||
142 | Transition transition, | 134 | Transition transition, |
143 | Duration duration = const Duration(milliseconds: 400)}) { | 135 | Duration duration = const Duration(milliseconds: 400)}) { |
144 | return key.currentState.pushReplacement(GetRoute( | 136 | return key.currentState.pushReplacement(GetRoute( |
145 | - opaque: rebuildRoutes, | 137 | + rebuildRoutes: rebuildRoutes, |
146 | page: page, | 138 | page: page, |
147 | - transition: transition ?? Platform.isIOS | ||
148 | - ? Transition.cupertino | ||
149 | - : Transition.fade, | 139 | + transition: transition, |
150 | duration: duration)); | 140 | duration: duration)); |
151 | } | 141 | } |
152 | 142 | ||
@@ -158,12 +148,7 @@ class Get { | @@ -158,12 +148,7 @@ class Get { | ||
158 | var route = (Route<dynamic> rota) => false; | 148 | var route = (Route<dynamic> rota) => false; |
159 | return key.currentState.pushAndRemoveUntil( | 149 | return key.currentState.pushAndRemoveUntil( |
160 | GetRoute( | 150 | GetRoute( |
161 | - opaque: rebuildRoutes, | ||
162 | - page: page, | ||
163 | - transition: transition ?? Platform.isIOS | ||
164 | - ? Transition.cupertino | ||
165 | - : Transition.fade, | ||
166 | - ), | 151 | + rebuildRoutes: rebuildRoutes, page: page, transition: transition), |
167 | predicate ?? route); | 152 | predicate ?? route); |
168 | } | 153 | } |
169 | 154 |
lib/src/platform/platform.dart
0 → 100644
1 | +import 'platform_web.dart' if (dart.library.io) 'platform_io.dart'; | ||
2 | + | ||
3 | +class GetPlatform { | ||
4 | + static bool get isWeb => GeneralPlatform.isWeb; | ||
5 | + static bool get isMacOS => GeneralPlatform.isMacOS; | ||
6 | + static bool get isWindows => GeneralPlatform.isWindows; | ||
7 | + static bool get isLinux => GeneralPlatform.isLinux; | ||
8 | + static bool get isAndroid => GeneralPlatform.isAndroid; | ||
9 | + static bool get isIOS => GeneralPlatform.isIOS; | ||
10 | + static bool get isFuchsia => GeneralPlatform.isFuchsia; | ||
11 | +} |
lib/src/platform/platform_io.dart
0 → 100644
1 | +import 'dart:io'; | ||
2 | + | ||
3 | +class GeneralPlatform { | ||
4 | + static bool get isWeb => false; | ||
5 | + static bool get isMacOS => Platform.isMacOS; | ||
6 | + static bool get isWindows => Platform.isWindows; | ||
7 | + static bool get isLinux => Platform.isLinux; | ||
8 | + static bool get isAndroid => Platform.isAndroid; | ||
9 | + static bool get isIOS => Platform.isIOS; | ||
10 | + static bool get isFuchsia => Platform.isFuchsia; | ||
11 | +} |
lib/src/platform/platform_web.dart
0 → 100644
lib/src/routes/default_route.dart
0 → 100644
1 | +import 'package:flutter/material.dart'; | ||
2 | +import 'getroute_cupertino.dart'; | ||
3 | +import 'getroute_material.dart'; | ||
4 | +import 'transitions_type.dart'; | ||
5 | +import 'package:get/get.dart'; | ||
6 | + | ||
7 | +// ignore: non_constant_identifier_names | ||
8 | +PageRoute<T> GetRoute<T>({ | ||
9 | + Key key, | ||
10 | + RouteSettings settings, | ||
11 | + String title, | ||
12 | + bool rebuildRoutes, | ||
13 | + bool maintainState = true, | ||
14 | + @required Widget page, | ||
15 | + Transition transition, | ||
16 | + Curve curve = Curves.linear, | ||
17 | + Alignment alignment, | ||
18 | + Duration duration = const Duration(milliseconds: 400), | ||
19 | + bool fullscreenDialog = false, | ||
20 | +}) { | ||
21 | + return GetPlatform.isIOS | ||
22 | + ? GetCupertino( | ||
23 | + settings: settings, | ||
24 | + title: title, | ||
25 | + opaque: rebuildRoutes ?? true, | ||
26 | + maintainState: maintainState, | ||
27 | + page: page, | ||
28 | + transition: transition ?? Transition.cupertino, | ||
29 | + curve: curve, | ||
30 | + alignment: alignment, | ||
31 | + duration: duration, | ||
32 | + fullscreenDialog: fullscreenDialog) | ||
33 | + : GetMaterial( | ||
34 | + settings: settings, | ||
35 | + opaque: rebuildRoutes ?? false, | ||
36 | + maintainState: maintainState, | ||
37 | + page: page, | ||
38 | + transition: transition ?? Transition.fade, | ||
39 | + curve: curve, | ||
40 | + alignment: alignment, | ||
41 | + duration: duration, | ||
42 | + fullscreenDialog: fullscreenDialog); | ||
43 | +} |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | - | ||
3 | import 'transitions_type.dart'; | 2 | import 'transitions_type.dart'; |
4 | 3 | ||
5 | -class GetRoute<T> extends PageRouteBuilder<T> { | 4 | +class GetMaterial<T> extends PageRouteBuilder<T> { |
6 | /// Construct a Modified PageRoute whose contents are defined by child. | 5 | /// Construct a Modified PageRoute whose contents are defined by child. |
7 | /// The values of [child], [maintainState], [opaque], and [fullScreenDialog] must not | 6 | /// The values of [child], [maintainState], [opaque], and [fullScreenDialog] must not |
8 | /// be null. | 7 | /// be null. |
9 | - GetRoute({ | 8 | + GetMaterial({ |
10 | Key key, | 9 | Key key, |
11 | RouteSettings settings, | 10 | RouteSettings settings, |
12 | this.opaque = false, | 11 | this.opaque = false, |
@@ -200,13 +199,13 @@ class GetRoute<T> extends PageRouteBuilder<T> { | @@ -200,13 +199,13 @@ class GetRoute<T> extends PageRouteBuilder<T> { | ||
200 | 199 | ||
201 | // @override | 200 | // @override |
202 | // bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) { | 201 | // bool canTransitionFrom(TransitionRoute<dynamic> previousRoute) { |
203 | - // return previousRoute is GetRoute || previousRoute is CupertinoPageRoute; | 202 | + // return previousRoute is GetMaterial || previousRoute is CupertinoPageRoute; |
204 | // } | 203 | // } |
205 | 204 | ||
206 | // @override | 205 | // @override |
207 | // bool canTransitionTo(TransitionRoute<dynamic> nextRoute) { | 206 | // bool canTransitionTo(TransitionRoute<dynamic> nextRoute) { |
208 | // // Don't perform outgoing animation if the next route is a fullscreen dialog. | 207 | // // Don't perform outgoing animation if the next route is a fullscreen dialog. |
209 | - // return (nextRoute is GetRoute && !nextRoute.fullscreenDialog) || | 208 | + // return (nextRoute is GetMaterial && !nextRoute.fullscreenDialog) || |
210 | // (nextRoute is CupertinoPageRoute && !nextRoute.fullscreenDialog); | 209 | // (nextRoute is CupertinoPageRoute && !nextRoute.fullscreenDialog); |
211 | // } | 210 | // } |
212 | 211 |
lib/src/sample.dart
deleted
100644 → 0
1 | -import 'dart:math'; | ||
2 | -import 'dart:ui' show lerpDouble; | ||
3 | - | ||
4 | -import 'package:flutter/cupertino.dart'; | ||
5 | -import 'package:flutter/foundation.dart'; | ||
6 | -import 'package:flutter/gestures.dart'; | ||
7 | - | ||
8 | -const double _kBackGestureWidth = 20.0; | ||
9 | -const double _kMinFlingVelocity = 1.0; | ||
10 | -const int _kMaxDroppedSwipePageForwardAnimationTime = 800; // Milliseconds. | ||
11 | - | ||
12 | -// The maximum time for a page to get reset to it's original position if the | ||
13 | -// user releases a page mid swipe. | ||
14 | -const int _kMaxPageBackAnimationTime = 300; | ||
15 | - | ||
16 | -class GetCupertino<T> extends PageRoute<T> { | ||
17 | - /// Creates a page route for use in an iOS designed app. | ||
18 | - /// | ||
19 | - /// The [builder], [maintainState], and [fullscreenDialog] arguments must not | ||
20 | - /// be null. | ||
21 | - GetCupertino({ | ||
22 | - @required this.builder, | ||
23 | - this.title, | ||
24 | - RouteSettings settings, | ||
25 | - this.maintainState = true, | ||
26 | - bool fullscreenDialog = false, | ||
27 | - }) : assert(builder != null), | ||
28 | - assert(maintainState != null), | ||
29 | - assert(fullscreenDialog != null), | ||
30 | - assert(opaque), | ||
31 | - super(settings: settings, fullscreenDialog: fullscreenDialog); | ||
32 | - | ||
33 | - /// Builds the primary contents of the route. | ||
34 | - final WidgetBuilder builder; | ||
35 | - | ||
36 | - /// A title string for this route. | ||
37 | - /// | ||
38 | - /// Used to auto-populate [CupertinoNavigationBar] and | ||
39 | - /// [CupertinoSliverNavigationBar]'s `middle`/`largeTitle` widgets when | ||
40 | - /// one is not manually supplied. | ||
41 | - final String title; | ||
42 | - | ||
43 | - ValueNotifier<String> _previousTitle; | ||
44 | - | ||
45 | - /// The title string of the previous [GetCupertino]. | ||
46 | - /// | ||
47 | - /// The [ValueListenable]'s value is readable after the route is installed | ||
48 | - /// onto a [Navigator]. The [ValueListenable] will also notify its listeners | ||
49 | - /// if the value changes (such as by replacing the previous route). | ||
50 | - /// | ||
51 | - /// The [ValueListenable] itself will be null before the route is installed. | ||
52 | - /// Its content value will be null if the previous route has no title or | ||
53 | - /// is not a [GetCupertino]. | ||
54 | - /// | ||
55 | - /// See also: | ||
56 | - /// | ||
57 | - /// * [ValueListenableBuilder], which can be used to listen and rebuild | ||
58 | - /// widgets based on a ValueListenable. | ||
59 | - ValueListenable<String> get previousTitle { | ||
60 | - assert( | ||
61 | - _previousTitle != null, | ||
62 | - 'Cannot read the previousTitle for a route that has not yet been installed', | ||
63 | - ); | ||
64 | - return _previousTitle; | ||
65 | - } | ||
66 | - | ||
67 | - @override | ||
68 | - void didChangePrevious(Route<dynamic> previousRoute) { | ||
69 | - final String previousTitleString = | ||
70 | - previousRoute is GetCupertino ? previousRoute.title : null; | ||
71 | - if (_previousTitle == null) { | ||
72 | - _previousTitle = ValueNotifier<String>(previousTitleString); | ||
73 | - } else { | ||
74 | - _previousTitle.value = previousTitleString; | ||
75 | - } | ||
76 | - super.didChangePrevious(previousRoute); | ||
77 | - } | ||
78 | - | ||
79 | - @override | ||
80 | - final bool maintainState; | ||
81 | - | ||
82 | - @override | ||
83 | - // A relatively rigorous eyeball estimation. | ||
84 | - Duration get transitionDuration => const Duration(milliseconds: 400); | ||
85 | - | ||
86 | - @override | ||
87 | - Color get barrierColor => null; | ||
88 | - | ||
89 | - @override | ||
90 | - String get barrierLabel => null; | ||
91 | - | ||
92 | - @override | ||
93 | - bool canTransitionTo(TransitionRoute<dynamic> nextRoute) { | ||
94 | - // Don't perform outgoing animation if the next route is a fullscreen dialog. | ||
95 | - return nextRoute is GetCupertino && !nextRoute.fullscreenDialog; | ||
96 | - } | ||
97 | - | ||
98 | - /// True if an iOS-style back swipe pop gesture is currently underway for [route]. | ||
99 | - /// | ||
100 | - /// This just check the route's [NavigatorState.userGestureInProgress]. | ||
101 | - /// | ||
102 | - /// See also: | ||
103 | - /// | ||
104 | - /// * [popGestureEnabled], which returns true if a user-triggered pop gesture | ||
105 | - /// would be allowed. | ||
106 | - static bool isPopGestureInProgress(PageRoute<dynamic> route) { | ||
107 | - return route.navigator.userGestureInProgress; | ||
108 | - } | ||
109 | - | ||
110 | - /// True if an iOS-style back swipe pop gesture is currently underway for this route. | ||
111 | - /// | ||
112 | - /// See also: | ||
113 | - /// | ||
114 | - /// * [isPopGestureInProgress], which returns true if a Cupertino pop gesture | ||
115 | - /// is currently underway for specific route. | ||
116 | - /// * [popGestureEnabled], which returns true if a user-triggered pop gesture | ||
117 | - /// would be allowed. | ||
118 | - bool get popGestureInProgress => isPopGestureInProgress(this); | ||
119 | - | ||
120 | - /// Whether a pop gesture can be started by the user. | ||
121 | - /// | ||
122 | - /// Returns true if the user can edge-swipe to a previous route. | ||
123 | - /// | ||
124 | - /// Returns false once [isPopGestureInProgress] is true, but | ||
125 | - /// [isPopGestureInProgress] can only become true if [popGestureEnabled] was | ||
126 | - /// true first. | ||
127 | - /// | ||
128 | - /// This should only be used between frames, not during build. | ||
129 | - bool get popGestureEnabled => _isPopGestureEnabled(this); | ||
130 | - | ||
131 | - static bool _isPopGestureEnabled<T>(PageRoute<T> route) { | ||
132 | - // If there's nothing to go back to, then obviously we don't support | ||
133 | - // the back gesture. | ||
134 | - if (route.isFirst) return false; | ||
135 | - // If the route wouldn't actually pop if we popped it, then the gesture | ||
136 | - // would be really confusing (or would skip internal routes), so disallow it. | ||
137 | - if (route.willHandlePopInternally) return false; | ||
138 | - // If attempts to dismiss this route might be vetoed such as in a page | ||
139 | - // with forms, then do not allow the user to dismiss the route with a swipe. | ||
140 | - if (route.hasScopedWillPopCallback) return false; | ||
141 | - // Fullscreen dialogs aren't dismissible by back swipe. | ||
142 | - if (route.fullscreenDialog) return false; | ||
143 | - // If we're in an animation already, we cannot be manually swiped. | ||
144 | - if (route.animation.status != AnimationStatus.completed) return false; | ||
145 | - // If we're being popped into, we also cannot be swiped until the pop above | ||
146 | - // it completes. This translates to our secondary animation being | ||
147 | - // dismissed. | ||
148 | - if (route.secondaryAnimation.status != AnimationStatus.dismissed) | ||
149 | - return false; | ||
150 | - // If we're in a gesture already, we cannot start another. | ||
151 | - if (isPopGestureInProgress(route)) return false; | ||
152 | - | ||
153 | - // Looks like a back gesture would be welcome! | ||
154 | - return true; | ||
155 | - } | ||
156 | - | ||
157 | - @override | ||
158 | - Widget buildPage(BuildContext context, Animation<double> animation, | ||
159 | - Animation<double> secondaryAnimation) { | ||
160 | - final Widget child = builder(context); | ||
161 | - final Widget result = Semantics( | ||
162 | - scopesRoute: true, | ||
163 | - explicitChildNodes: true, | ||
164 | - child: child, | ||
165 | - ); | ||
166 | - assert(() { | ||
167 | - if (child == null) { | ||
168 | - throw FlutterError.fromParts(<DiagnosticsNode>[ | ||
169 | - ErrorSummary( | ||
170 | - 'The builder for route "${settings.name}" returned null.'), | ||
171 | - ErrorDescription('Route builders must never return null.'), | ||
172 | - ]); | ||
173 | - } | ||
174 | - return true; | ||
175 | - }()); | ||
176 | - return result; | ||
177 | - } | ||
178 | - | ||
179 | - // Called by _CupertinoBackGestureDetector when a pop ("back") drag start | ||
180 | - // gesture is detected. The returned controller handles all of the subsequent | ||
181 | - // drag events. | ||
182 | - static _CupertinoBackGestureController<T> _startPopGesture<T>( | ||
183 | - PageRoute<T> route) { | ||
184 | - assert(_isPopGestureEnabled(route)); | ||
185 | - | ||
186 | - return _CupertinoBackGestureController<T>( | ||
187 | - navigator: route.navigator, | ||
188 | - controller: route.controller, // protected access | ||
189 | - ); | ||
190 | - } | ||
191 | - | ||
192 | - /// Returns a [CupertinoFullscreenDialogTransition] if [route] is a full | ||
193 | - /// screen dialog, otherwise a [CupertinoPageTransition] is returned. | ||
194 | - /// | ||
195 | - /// Used by [GetCupertino.buildTransitions]. | ||
196 | - /// | ||
197 | - /// This method can be applied to any [PageRoute], not just | ||
198 | - /// [GetCupertino]. It's typically used to provide a Cupertino style | ||
199 | - /// horizontal transition for material widgets when the target platform | ||
200 | - /// is [TargetPlatform.iOS]. | ||
201 | - /// | ||
202 | - /// See also: | ||
203 | - /// | ||
204 | - /// * [CupertinoPageTransitionsBuilder], which uses this method to define a | ||
205 | - /// [PageTransitionsBuilder] for the [PageTransitionsTheme]. | ||
206 | - static Widget buildPageTransitions<T>( | ||
207 | - PageRoute<T> route, | ||
208 | - BuildContext context, | ||
209 | - Animation<double> animation, | ||
210 | - Animation<double> secondaryAnimation, | ||
211 | - Widget child, | ||
212 | - ) { | ||
213 | - if (route.fullscreenDialog) { | ||
214 | - return CupertinoFullscreenDialogTransition( | ||
215 | - animation: animation, | ||
216 | - child: child, | ||
217 | - ); | ||
218 | - } else { | ||
219 | - return CupertinoPageTransition( | ||
220 | - primaryRouteAnimation: animation, | ||
221 | - secondaryRouteAnimation: secondaryAnimation, | ||
222 | - // Check if the route has an animation that's currently participating | ||
223 | - // in a back swipe gesture. | ||
224 | - // | ||
225 | - // In the middle of a back gesture drag, let the transition be linear to | ||
226 | - // match finger motions. | ||
227 | - linearTransition: isPopGestureInProgress(route), | ||
228 | - child: _CupertinoBackGestureDetector<T>( | ||
229 | - enabledCallback: () => _isPopGestureEnabled<T>(route), | ||
230 | - onStartPopGesture: () => _startPopGesture<T>(route), | ||
231 | - child: child, | ||
232 | - ), | ||
233 | - ); | ||
234 | - } | ||
235 | - } | ||
236 | - | ||
237 | - @override | ||
238 | - Widget buildTransitions(BuildContext context, Animation<double> animation, | ||
239 | - Animation<double> secondaryAnimation, Widget child) { | ||
240 | - return buildPageTransitions<T>( | ||
241 | - this, context, animation, secondaryAnimation, child); | ||
242 | - } | ||
243 | - | ||
244 | - @override | ||
245 | - String get debugLabel => '${super.debugLabel}(${settings.name})'; | ||
246 | -} | ||
247 | - | ||
248 | -class _CupertinoBackGestureDetector<T> extends StatefulWidget { | ||
249 | - const _CupertinoBackGestureDetector({ | ||
250 | - Key key, | ||
251 | - @required this.enabledCallback, | ||
252 | - @required this.onStartPopGesture, | ||
253 | - @required this.child, | ||
254 | - }) : assert(enabledCallback != null), | ||
255 | - assert(onStartPopGesture != null), | ||
256 | - assert(child != null), | ||
257 | - super(key: key); | ||
258 | - | ||
259 | - final Widget child; | ||
260 | - | ||
261 | - final ValueGetter<bool> enabledCallback; | ||
262 | - | ||
263 | - final ValueGetter<_CupertinoBackGestureController<T>> onStartPopGesture; | ||
264 | - | ||
265 | - @override | ||
266 | - _CupertinoBackGestureDetectorState<T> createState() => | ||
267 | - _CupertinoBackGestureDetectorState<T>(); | ||
268 | -} | ||
269 | - | ||
270 | -class _CupertinoBackGestureDetectorState<T> | ||
271 | - extends State<_CupertinoBackGestureDetector<T>> { | ||
272 | - _CupertinoBackGestureController<T> _backGestureController; | ||
273 | - | ||
274 | - HorizontalDragGestureRecognizer _recognizer; | ||
275 | - | ||
276 | - @override | ||
277 | - void initState() { | ||
278 | - super.initState(); | ||
279 | - _recognizer = HorizontalDragGestureRecognizer(debugOwner: this) | ||
280 | - ..onStart = _handleDragStart | ||
281 | - ..onUpdate = _handleDragUpdate | ||
282 | - ..onEnd = _handleDragEnd | ||
283 | - ..onCancel = _handleDragCancel; | ||
284 | - } | ||
285 | - | ||
286 | - @override | ||
287 | - void dispose() { | ||
288 | - _recognizer.dispose(); | ||
289 | - super.dispose(); | ||
290 | - } | ||
291 | - | ||
292 | - void _handleDragStart(DragStartDetails details) { | ||
293 | - assert(mounted); | ||
294 | - assert(_backGestureController == null); | ||
295 | - _backGestureController = widget.onStartPopGesture(); | ||
296 | - } | ||
297 | - | ||
298 | - void _handleDragUpdate(DragUpdateDetails details) { | ||
299 | - assert(mounted); | ||
300 | - assert(_backGestureController != null); | ||
301 | - _backGestureController.dragUpdate( | ||
302 | - _convertToLogical(details.primaryDelta / context.size.width)); | ||
303 | - } | ||
304 | - | ||
305 | - void _handleDragEnd(DragEndDetails details) { | ||
306 | - assert(mounted); | ||
307 | - assert(_backGestureController != null); | ||
308 | - _backGestureController.dragEnd(_convertToLogical( | ||
309 | - details.velocity.pixelsPerSecond.dx / context.size.width)); | ||
310 | - _backGestureController = null; | ||
311 | - } | ||
312 | - | ||
313 | - void _handleDragCancel() { | ||
314 | - assert(mounted); | ||
315 | - // This can be called even if start is not called, paired with the "down" event | ||
316 | - // that we don't consider here. | ||
317 | - _backGestureController?.dragEnd(0.0); | ||
318 | - _backGestureController = null; | ||
319 | - } | ||
320 | - | ||
321 | - void _handlePointerDown(PointerDownEvent event) { | ||
322 | - if (widget.enabledCallback()) _recognizer.addPointer(event); | ||
323 | - } | ||
324 | - | ||
325 | - double _convertToLogical(double value) { | ||
326 | - switch (Directionality.of(context)) { | ||
327 | - case TextDirection.rtl: | ||
328 | - return -value; | ||
329 | - case TextDirection.ltr: | ||
330 | - return value; | ||
331 | - } | ||
332 | - return null; | ||
333 | - } | ||
334 | - | ||
335 | - @override | ||
336 | - Widget build(BuildContext context) { | ||
337 | - assert(debugCheckHasDirectionality(context)); | ||
338 | - // For devices with notches, the drag area needs to be larger on the side | ||
339 | - // that has the notch. | ||
340 | - double dragAreaWidth = Directionality.of(context) == TextDirection.ltr | ||
341 | - ? MediaQuery.of(context).padding.left | ||
342 | - : MediaQuery.of(context).padding.right; | ||
343 | - dragAreaWidth = max(dragAreaWidth, _kBackGestureWidth); | ||
344 | - return Stack( | ||
345 | - fit: StackFit.passthrough, | ||
346 | - children: <Widget>[ | ||
347 | - widget.child, | ||
348 | - PositionedDirectional( | ||
349 | - start: 0.0, | ||
350 | - width: dragAreaWidth, | ||
351 | - top: 0.0, | ||
352 | - bottom: 0.0, | ||
353 | - child: Listener( | ||
354 | - onPointerDown: _handlePointerDown, | ||
355 | - behavior: HitTestBehavior.translucent, | ||
356 | - ), | ||
357 | - ), | ||
358 | - ], | ||
359 | - ); | ||
360 | - } | ||
361 | -} | ||
362 | - | ||
363 | -class _CupertinoBackGestureController<T> { | ||
364 | - /// Creates a controller for an iOS-style back gesture. | ||
365 | - /// | ||
366 | - /// The [navigator] and [controller] arguments must not be null. | ||
367 | - _CupertinoBackGestureController({ | ||
368 | - @required this.navigator, | ||
369 | - @required this.controller, | ||
370 | - }) : assert(navigator != null), | ||
371 | - assert(controller != null) { | ||
372 | - navigator.didStartUserGesture(); | ||
373 | - } | ||
374 | - | ||
375 | - final AnimationController controller; | ||
376 | - final NavigatorState navigator; | ||
377 | - | ||
378 | - /// The drag gesture has changed by [fractionalDelta]. The total range of the | ||
379 | - /// drag should be 0.0 to 1.0. | ||
380 | - void dragUpdate(double delta) { | ||
381 | - controller.value -= delta; | ||
382 | - } | ||
383 | - | ||
384 | - /// The drag gesture has ended with a horizontal motion of | ||
385 | - /// [fractionalVelocity] as a fraction of screen width per second. | ||
386 | - void dragEnd(double velocity) { | ||
387 | - // Fling in the appropriate direction. | ||
388 | - // AnimationController.fling is guaranteed to | ||
389 | - // take at least one frame. | ||
390 | - // | ||
391 | - // This curve has been determined through rigorously eyeballing native iOS | ||
392 | - // animations. | ||
393 | - const Curve animationCurve = Curves.fastLinearToSlowEaseIn; | ||
394 | - bool animateForward; | ||
395 | - | ||
396 | - // If the user releases the page before mid screen with sufficient velocity, | ||
397 | - // or after mid screen, we should animate the page out. Otherwise, the page | ||
398 | - // should be animated back in. | ||
399 | - if (velocity.abs() >= _kMinFlingVelocity) | ||
400 | - animateForward = velocity <= 0; | ||
401 | - else | ||
402 | - animateForward = controller.value > 0.5; | ||
403 | - | ||
404 | - if (animateForward) { | ||
405 | - // The closer the panel is to dismissing, the shorter the animation is. | ||
406 | - // We want to cap the animation time, but we want to use a linear curve | ||
407 | - // to determine it. | ||
408 | - final int droppedPageForwardAnimationTime = min( | ||
409 | - lerpDouble( | ||
410 | - _kMaxDroppedSwipePageForwardAnimationTime, 0, controller.value) | ||
411 | - .floor(), | ||
412 | - _kMaxPageBackAnimationTime, | ||
413 | - ); | ||
414 | - controller.animateTo(1.0, | ||
415 | - duration: Duration(milliseconds: droppedPageForwardAnimationTime), | ||
416 | - curve: animationCurve); | ||
417 | - } else { | ||
418 | - // This route is destined to pop at this point. Reuse navigator's pop. | ||
419 | - navigator.pop(); | ||
420 | - | ||
421 | - // The popping may have finished inline if already at the target destination. | ||
422 | - if (controller.isAnimating) { | ||
423 | - // Otherwise, use a custom popping animation duration and curve. | ||
424 | - final int droppedPageBackAnimationTime = lerpDouble( | ||
425 | - 0, _kMaxDroppedSwipePageForwardAnimationTime, controller.value) | ||
426 | - .floor(); | ||
427 | - controller.animateBack(0.0, | ||
428 | - duration: Duration(milliseconds: droppedPageBackAnimationTime), | ||
429 | - curve: animationCurve); | ||
430 | - } | ||
431 | - } | ||
432 | - | ||
433 | - if (controller.isAnimating) { | ||
434 | - // Keep the userGestureInProgress in true state so we don't change the | ||
435 | - // curve of the page transition mid-flight since CupertinoPageTransition | ||
436 | - // depends on userGestureInProgress. | ||
437 | - AnimationStatusListener animationStatusCallback; | ||
438 | - animationStatusCallback = (AnimationStatus status) { | ||
439 | - navigator.didStopUserGesture(); | ||
440 | - controller.removeStatusListener(animationStatusCallback); | ||
441 | - }; | ||
442 | - controller.addStatusListener(animationStatusCallback); | ||
443 | - } else { | ||
444 | - navigator.didStopUserGesture(); | ||
445 | - } | ||
446 | - } | ||
447 | -} |
@@ -2,7 +2,7 @@ import 'dart:async'; | @@ -2,7 +2,7 @@ import 'dart:async'; | ||
2 | import 'dart:ui'; | 2 | 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 'routes.dart'; | 5 | +import 'package:get/get.dart'; |
6 | import 'snack_route.dart' as route; | 6 | import 'snack_route.dart' as route; |
7 | 7 | ||
8 | typedef void SnackStatusCallback(SnackStatus status); | 8 | typedef void SnackStatusCallback(SnackStatus status); |
1 | name: get | 1 | name: get |
2 | -description: A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars easily with no context. | ||
3 | -version: 1.12.0-dev | 2 | +description: Navigate between screens, display snackbars, dialogs and bottomSheets, from anywhere in your code without context with Get. |
3 | +version: 1.13.1-dev | ||
4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
5 | 5 | ||
6 | environment: | 6 | environment: |
-
Please register or login to post a comment