Showing
8 changed files
with
237 additions
and
79 deletions
@@ -98,8 +98,24 @@ | @@ -98,8 +98,24 @@ | ||
98 | - Added customs transitions | 98 | - Added customs transitions |
99 | - Improve dialogs performance | 99 | - Improve dialogs performance |
100 | 100 | ||
101 | - ## [1.7.1] | 101 | +## [1.7.1] |
102 | -Fix docs | 102 | -Fix docs |
103 | 103 | ||
104 | +## [1.7.2] | ||
105 | + -Fix bottomsheet on macos | ||
106 | + | ||
107 | +## [1.7.3] | ||
108 | + -Added transitions docs | ||
109 | + | ||
110 | +## [1.7.4] | ||
111 | + -Fix dialog child error | ||
112 | + | ||
113 | +## [1.8.0] | ||
114 | + -Add Get.close method. | ||
115 | + -Add many Snackbars features | ||
116 | + | ||
117 | +## [1.8.1] | ||
118 | + -Fix new snackbar features | ||
119 | + | ||
104 | 120 | ||
105 | 121 |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | A consistent navigation library that lets you navigate between screens, open dialogs/bottomSheets, and display snackbars from anywhere in your code without context. | 3 | A consistent navigation library that lets you navigate between screens, open dialogs/bottomSheets, and display snackbars from anywhere in your code without context. |
4 | ## Getting Started | 4 | ## Getting Started |
5 | 5 | ||
6 | -Flutter's conventional navigation has a lot of unnecessary boilerplate, requires context to navigate between screens, open dialogs, and snacking is really painful. | 6 | +Flutter's conventional navigation has a lot of unnecessary boilerplate, requires context to navigate between screens, open dialogs, and use snackbars on framework is really painful. |
7 | In addition, with each route navigation, all of your screens below MaterialApp are rebuilt, often causing RAM and CPU bottlenecks. | 7 | In addition, with each route navigation, all of your screens below MaterialApp are rebuilt, often causing RAM and CPU bottlenecks. |
8 | I worked on a pull to fix it in the framework, and seeing how things work I realized that a lot of cliche code could be avoided to get clean and concise code. | 8 | I worked on a pull to fix it in the framework, and seeing how things work I realized that a lot of cliche code could be avoided to get clean and concise code. |
9 | With that in mind, I created this library that will change the way you work with the Framework and save your life from cliche code, | 9 | With that in mind, I created this library that will change the way you work with the Framework and save your life from cliche code, |
@@ -15,7 +15,7 @@ Add this to your package's pubspec.yaml file: | @@ -15,7 +15,7 @@ Add this to your package's pubspec.yaml file: | ||
15 | 15 | ||
16 | ``` | 16 | ``` |
17 | dependencies: | 17 | dependencies: |
18 | - get: ^1.7.4 | 18 | + get: ^1.8.1 |
19 | ``` | 19 | ``` |
20 | 20 | ||
21 | And import it: | 21 | And import it: |
@@ -69,11 +69,7 @@ ex: | @@ -69,11 +69,7 @@ ex: | ||
69 | ```dart | 69 | ```dart |
70 | if(data == 'sucess') madeAnything(); | 70 | if(data == 'sucess') madeAnything(); |
71 | ``` | 71 | ``` |
72 | -### Others methods (docs will be added soon): | ||
73 | -Get.removeRoute // remove one route. | ||
74 | -Get.until // back repeatedly until the predicate returns true. | ||
75 | -Get.offUntil // go to next route and remove all the previous routes until the predicate returns true. | ||
76 | -Get.offNamedUntil // go to next named route and remove all the previous routes until the predicate returns true. | 72 | + |
77 | 73 | ||
78 | ### SnackBars | 74 | ### SnackBars |
79 | To show a modern snackbar: | 75 | To show a modern snackbar: |
@@ -81,20 +77,54 @@ To show a modern snackbar: | @@ -81,20 +77,54 @@ To show a modern snackbar: | ||
81 | Get.snackbar('Hi', 'i am a modern snackbar'); | 77 | Get.snackbar('Hi', 'i am a modern snackbar'); |
82 | ``` | 78 | ``` |
83 | To have a simple SnackBar with Flutter, you must get the context of Scaffold, or you must use a GlobalKey attached to your Scaffold, | 79 | To have a simple SnackBar with Flutter, you must get the context of Scaffold, or you must use a GlobalKey attached to your Scaffold, |
84 | -but with Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want with GetBar! | 80 | +but with Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want! |
85 | 81 | ||
86 | ```dart | 82 | ```dart |
87 | - GetBar( | ||
88 | - title: "Hey i'm a Get SnackBar!", | ||
89 | - message: | ||
90 | - "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", | ||
91 | - icon: Icon(Icons.alarm), | 83 | + Get.snackbar( |
84 | + "Hey i'm a Get SnackBar!", // title | ||
85 | + "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message | ||
86 | + icon: Icon(Icons.alarm), | ||
92 | shouldIconPulse: true, | 87 | shouldIconPulse: true, |
93 | onTap:(){}, | 88 | onTap:(){}, |
94 | barBlur: 20, | 89 | barBlur: 20, |
95 | isDismissible: true, | 90 | isDismissible: true, |
96 | duration: Duration(seconds: 3), | 91 | duration: Duration(seconds: 3), |
97 | - )..show(); | 92 | + ); |
93 | + | ||
94 | + ////////// ALL FEATURES ////////// | ||
95 | + // Color colorText, | ||
96 | + // Duration duration, | ||
97 | + // SnackPosition snackPosition, | ||
98 | + // Widget titleText, | ||
99 | + // Widget messageText, | ||
100 | + // Widget icon, | ||
101 | + // bool shouldIconPulse, | ||
102 | + // double maxWidth, | ||
103 | + // EdgeInsets margin, | ||
104 | + // EdgeInsets padding, | ||
105 | + // double borderRadius, | ||
106 | + // Color borderColor, | ||
107 | + // double borderWidth, | ||
108 | + // Color backgroundColor, | ||
109 | + // Color leftBarIndicatorColor, | ||
110 | + // List<BoxShadow> boxShadows, | ||
111 | + // Gradient backgroundGradient, | ||
112 | + // FlatButton mainButton, | ||
113 | + // OnTap onTap, | ||
114 | + // bool isDismissible, | ||
115 | + // bool showProgressIndicator, | ||
116 | + // AnimationController progressIndicatorController, | ||
117 | + // Color progressIndicatorBackgroundColor, | ||
118 | + // Animation<Color> progressIndicatorValueColor, | ||
119 | + // SnackStyle snackStyle, | ||
120 | + // Curve forwardAnimationCurve, | ||
121 | + // Curve reverseAnimationCurve, | ||
122 | + // Duration animationDuration, | ||
123 | + // double barBlur, | ||
124 | + // double overlayBlur, | ||
125 | + // Color overlayColor, | ||
126 | + // Form userInputForm | ||
127 | + /////////////////////////////////// | ||
98 | ``` | 128 | ``` |
99 | ### Dialogs | 129 | ### Dialogs |
100 | 130 | ||
@@ -183,15 +213,10 @@ void main() { | @@ -183,15 +213,10 @@ void main() { | ||
183 | } | 213 | } |
184 | ``` | 214 | ``` |
185 | 215 | ||
186 | -### Important!!! COPY THE ROUTER CLASS BELOW: | 216 | +### COPY THE ROUTER CLASS BELOW: |
187 | 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. | 217 | 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. |
188 | - | ||
189 | -We suggest that you copy this class for 3 reasons: | ||
190 | -1- You must define an escape route if you accidentally set a wrong route. This example already contains this. | ||
191 | - | ||
192 | -2- Flutter_Web does not provide friendly urls(no matter how you set the route, it will always return to the main page after the page is reloaded and the route is not displayed in the url with default navigation), but Get supports it! So, when a user enters yourflutterwebsite.com/support and exactly the support route is displayed, you need to pass the settings parameter to GetRoute, and this example already contemplates it! | ||
193 | - | ||
194 | -3- These routes are designed to work with GetRoute, not CupertinoPageRoute or MaterialPageRoute. Never put them here. | 218 | +#### Important!!! |
219 | +GetRoute has great performance optimizations that MaterialPageRoute and CupertinoPageRoute do not. It solves the main problems with memory leaks and unexpected reconstructions of the Flutter, so please do not insert MaterialPageRoute or CupertinoPageRoute here, or you will lose one of the main benefits of this lib, in addition to experiencing inconsistencies in the transitions. We recommend always using GetRoute, and if you need custom transitions, use PageRouteBuilder by adding the parameter 'opaque = false' to maintain compatibility with the library. | ||
195 | 220 | ||
196 | ```dart | 221 | ```dart |
197 | class Router { | 222 | class Router { |
@@ -199,18 +224,18 @@ class Router { | @@ -199,18 +224,18 @@ class Router { | ||
199 | switch (settings.name) { | 224 | switch (settings.name) { |
200 | case '/': | 225 | case '/': |
201 | return GetRoute( | 226 | return GetRoute( |
202 | - builder: (_) => SplashScreen(), | 227 | + page: SplashScreen(), |
203 | settings: settings, | 228 | settings: settings, |
204 | ); | 229 | ); |
205 | case '/Home': | 230 | case '/Home': |
206 | - return GetRoute(settings: settings, builder: (_) => Home(), transition: Transition.fade); | 231 | + return GetRoute(settings: settings, page: Home(), transition: Transition.fade); |
207 | case '/Chat': | 232 | case '/Chat': |
208 | - return GetRoute(settings: settings, builder: (_) => Chat(),transition: Transition.rightToLeft); | 233 | + return GetRoute(settings: settings, page: Chat(), transition: Transition.rightToLeft); |
209 | default: | 234 | default: |
210 | return GetRoute( | 235 | return GetRoute( |
211 | settings: settings, | 236 | settings: settings, |
212 | - transition: Transition.rotate | ||
213 | - builder: (_) => Scaffold( | 237 | + transition: Transition.fade, |
238 | + page: Scaffold( | ||
214 | body: Center( | 239 | body: Center( |
215 | child: Text('No route defined for ${settings.name}')), | 240 | child: Text('No route defined for ${settings.name}')), |
216 | )); | 241 | )); |
@@ -229,12 +254,7 @@ class FirstRoute extends StatelessWidget { | @@ -229,12 +254,7 @@ class FirstRoute extends StatelessWidget { | ||
229 | leading: IconButton( | 254 | leading: IconButton( |
230 | icon: Icon(Icons.add), | 255 | icon: Icon(Icons.add), |
231 | onPressed: () { | 256 | onPressed: () { |
232 | - GetBar( | ||
233 | - title: "Hey i'm a Get SnackBar!", | ||
234 | - message: | ||
235 | - "It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", | ||
236 | - duration: Duration(seconds: 3), | ||
237 | - )..show(); | 257 | + Get.snackbar("hi", "i am a modern snackbar"); |
238 | }, | 258 | }, |
239 | ), | 259 | ), |
240 | title: Text('First Route'), | 260 | title: Text('First Route'), |
@@ -271,4 +291,16 @@ class SecondRoute extends StatelessWidget { | @@ -271,4 +291,16 @@ class SecondRoute extends StatelessWidget { | ||
271 | } | 291 | } |
272 | ``` | 292 | ``` |
273 | 293 | ||
294 | +### Others methods (docs will be added soon): | ||
295 | + | ||
296 | +```dart | ||
297 | +Get.removeRoute() // remove one route. | ||
298 | + | ||
299 | +Get.until() // back repeatedly until the predicate returns true. | ||
300 | + | ||
301 | +Get.offUntil() // go to next route and remove all the previous routes until the predicate returns true. | ||
302 | + | ||
303 | +Get.offNamedUntil() // go to next named route and remove all the previous routes until the predicate returns true. | ||
304 | +``` | ||
305 | + | ||
274 | That is all. | 306 | That is all. |
@@ -46,3 +46,31 @@ class SecondRoute extends StatelessWidget { | @@ -46,3 +46,31 @@ class SecondRoute extends StatelessWidget { | ||
46 | ); | 46 | ); |
47 | } | 47 | } |
48 | } | 48 | } |
49 | + | ||
50 | +class Router { | ||
51 | + static Route<dynamic> generateRoute(RouteSettings settings) { | ||
52 | + switch (settings.name) { | ||
53 | + case '/': | ||
54 | + return GetRoute( | ||
55 | + page: SplashScreen(), | ||
56 | + settings: settings, | ||
57 | + ); | ||
58 | + case '/Home': | ||
59 | + return GetRoute( | ||
60 | + settings: settings, page: Home(), transition: Transition.fade); | ||
61 | + case '/Chat': | ||
62 | + return GetRoute( | ||
63 | + settings: settings, | ||
64 | + page: Chat(), | ||
65 | + transition: Transition.rightToLeft); | ||
66 | + default: | ||
67 | + return GetRoute( | ||
68 | + settings: settings, | ||
69 | + transition: Transition.rotate, | ||
70 | + page: Scaffold( | ||
71 | + body: | ||
72 | + Center(child: Text('No route defined for ${settings.name}')), | ||
73 | + )); | ||
74 | + } | ||
75 | + } | ||
76 | +} |
@@ -63,7 +63,7 @@ packages: | @@ -63,7 +63,7 @@ packages: | ||
63 | name: cupertino_icons | 63 | name: cupertino_icons |
64 | url: "https://pub.dartlang.org" | 64 | url: "https://pub.dartlang.org" |
65 | source: hosted | 65 | source: hosted |
66 | - version: "0.1.2" | 66 | + version: "0.1.3" |
67 | flutter: | 67 | flutter: |
68 | dependency: "direct main" | 68 | dependency: "direct main" |
69 | description: flutter | 69 | description: flutter |
@@ -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.0.2" | 83 | + version: "1.8.0" |
84 | image: | 84 | image: |
85 | dependency: transitive | 85 | dependency: transitive |
86 | description: | 86 | description: |
@@ -108,15 +108,12 @@ class _GetModalBottomSheet<T> extends StatefulWidget { | @@ -108,15 +108,12 @@ class _GetModalBottomSheet<T> extends StatefulWidget { | ||
108 | 108 | ||
109 | class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { | 109 | class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { |
110 | String _getRouteLabel(MaterialLocalizations localizations) { | 110 | String _getRouteLabel(MaterialLocalizations localizations) { |
111 | - switch (Theme.of(context).platform) { | ||
112 | - case TargetPlatform.iOS: | ||
113 | - case TargetPlatform.macOS: | ||
114 | - return ''; | ||
115 | - case TargetPlatform.android: | ||
116 | - case TargetPlatform.fuchsia: | ||
117 | - return localizations.dialogLabel; | 111 | + if ((Theme.of(context).platform == TargetPlatform.android) || |
112 | + (Theme.of(context).platform == TargetPlatform.fuchsia)) { | ||
113 | + return localizations.dialogLabel; | ||
114 | + } else { | ||
115 | + return ''; | ||
118 | } | 116 | } |
119 | - return null; | ||
120 | } | 117 | } |
121 | 118 | ||
122 | @override | 119 | @override |
@@ -9,13 +9,13 @@ class GetRoute<T> extends PageRouteBuilder<T> { | @@ -9,13 +9,13 @@ class GetRoute<T> extends PageRouteBuilder<T> { | ||
9 | RouteSettings settings, | 9 | RouteSettings settings, |
10 | this.opaque = false, | 10 | this.opaque = false, |
11 | this.maintainState = true, | 11 | this.maintainState = true, |
12 | - @required this.child, | ||
13 | - @required this.transition, | 12 | + @required this.page, |
13 | + this.transition = Transition.fade, | ||
14 | this.curve = Curves.linear, | 14 | this.curve = Curves.linear, |
15 | this.alignment, | 15 | this.alignment, |
16 | - this.duration = const Duration(milliseconds: 300), | 16 | + this.duration = const Duration(milliseconds: 400), |
17 | bool fullscreenDialog = false, | 17 | bool fullscreenDialog = false, |
18 | - }) : assert(child != null), | 18 | + }) : assert(page != null), |
19 | assert(maintainState != null), | 19 | assert(maintainState != null), |
20 | assert(fullscreenDialog != null), | 20 | assert(fullscreenDialog != null), |
21 | assert(opaque != null), | 21 | assert(opaque != null), |
@@ -23,7 +23,7 @@ class GetRoute<T> extends PageRouteBuilder<T> { | @@ -23,7 +23,7 @@ class GetRoute<T> extends PageRouteBuilder<T> { | ||
23 | fullscreenDialog: fullscreenDialog, | 23 | fullscreenDialog: fullscreenDialog, |
24 | pageBuilder: (BuildContext context, Animation<double> animation, | 24 | pageBuilder: (BuildContext context, Animation<double> animation, |
25 | Animation<double> secondaryAnimation) { | 25 | Animation<double> secondaryAnimation) { |
26 | - return child; | 26 | + return page; |
27 | }, | 27 | }, |
28 | transitionDuration: duration, | 28 | transitionDuration: duration, |
29 | settings: settings, | 29 | settings: settings, |
@@ -114,10 +114,10 @@ class GetRoute<T> extends PageRouteBuilder<T> { | @@ -114,10 +114,10 @@ class GetRoute<T> extends PageRouteBuilder<T> { | ||
114 | ); | 114 | ); |
115 | break; | 115 | break; |
116 | case Transition.rotate: | 116 | case Transition.rotate: |
117 | - return new RotationTransition( | 117 | + return RotationTransition( |
118 | alignment: alignment, | 118 | alignment: alignment, |
119 | turns: animation, | 119 | turns: animation, |
120 | - child: new ScaleTransition( | 120 | + child: ScaleTransition( |
121 | alignment: alignment, | 121 | alignment: alignment, |
122 | scale: animation, | 122 | scale: animation, |
123 | child: FadeTransition( | 123 | child: FadeTransition( |
@@ -211,7 +211,7 @@ class GetRoute<T> extends PageRouteBuilder<T> { | @@ -211,7 +211,7 @@ class GetRoute<T> extends PageRouteBuilder<T> { | ||
211 | @override | 211 | @override |
212 | String get debugLabel => '${super.debugLabel}(${settings.name})'; | 212 | String get debugLabel => '${super.debugLabel}(${settings.name})'; |
213 | 213 | ||
214 | - final Widget child; | 214 | + final Widget page; |
215 | 215 | ||
216 | final Transition transition; | 216 | final Transition transition; |
217 | 217 |
@@ -32,34 +32,46 @@ class Get { | @@ -32,34 +32,46 @@ class Get { | ||
32 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. | 32 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. |
33 | static to(Widget page, | 33 | static to(Widget page, |
34 | {bool rebuildRoutes = false, Transition transition = Transition.fade}) { | 34 | {bool rebuildRoutes = false, Transition transition = Transition.fade}) { |
35 | + // if (key.currentState.mounted) // add this if appear problems on future with route navigate | ||
36 | + // when widget don't mounted | ||
35 | return key.currentState.push( | 37 | return key.currentState.push( |
36 | - GetRoute(opaque: rebuildRoutes, child: page, transition: transition)); | 38 | + GetRoute(opaque: rebuildRoutes, page: page, transition: transition)); |
37 | } | 39 | } |
38 | 40 | ||
39 | /// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed | 41 | /// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed |
40 | /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior | 42 | /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior |
41 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. | 43 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. |
42 | static toNamed(String page, {arguments}) { | 44 | static toNamed(String page, {arguments}) { |
45 | + // if (key.currentState.mounted) // add this if appear problems on future with route navigate | ||
46 | + // when widget don't mounted | ||
43 | return key.currentState.pushNamed(page, arguments: arguments); | 47 | return key.currentState.pushNamed(page, arguments: arguments); |
44 | } | 48 | } |
45 | 49 | ||
46 | /// It replaces Navigator.pushReplacementNamed, but needs no context. | 50 | /// It replaces Navigator.pushReplacementNamed, but needs no context. |
47 | static offNamed(String page, {arguments}) { | 51 | static offNamed(String page, {arguments}) { |
52 | + // if (key.currentState.mounted) // add this if appear problems on future with route navigate | ||
53 | + // when widget don't mounted | ||
48 | return key.currentState.pushReplacementNamed(page, arguments: arguments); | 54 | return key.currentState.pushReplacementNamed(page, arguments: arguments); |
49 | } | 55 | } |
50 | 56 | ||
51 | /// It replaces Navigator.popUntil, but needs no context. | 57 | /// It replaces Navigator.popUntil, but needs no context. |
52 | static until(String page, predicate) { | 58 | static until(String page, predicate) { |
59 | + // if (key.currentState.mounted) // add this if appear problems on future with route navigate | ||
60 | + // when widget don't mounted | ||
53 | return key.currentState.popUntil(predicate); | 61 | return key.currentState.popUntil(predicate); |
54 | } | 62 | } |
55 | 63 | ||
56 | /// It replaces Navigator.pushAndRemoveUntil, but needs no context. | 64 | /// It replaces Navigator.pushAndRemoveUntil, but needs no context. |
57 | static offUntil(page, predicate) { | 65 | static offUntil(page, predicate) { |
66 | + // if (key.currentState.mounted) // add this if appear problems on future with route navigate | ||
67 | + // when widget don't mounted | ||
58 | return key.currentState.pushAndRemoveUntil(page, predicate); | 68 | return key.currentState.pushAndRemoveUntil(page, predicate); |
59 | } | 69 | } |
60 | 70 | ||
61 | /// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context. | 71 | /// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context. |
62 | static offNamedUntil(page, predicate) { | 72 | static offNamedUntil(page, predicate) { |
73 | + // if (key.currentState.mounted) // add this if appear problems on future with route navigate | ||
74 | + // when widget don't mounted | ||
63 | return key.currentState.pushNamedAndRemoveUntil(page, predicate); | 75 | return key.currentState.pushNamedAndRemoveUntil(page, predicate); |
64 | } | 76 | } |
65 | 77 | ||
@@ -83,6 +95,18 @@ class Get { | @@ -83,6 +95,18 @@ class Get { | ||
83 | return key.currentState.pop(result); | 95 | return key.currentState.pop(result); |
84 | } | 96 | } |
85 | 97 | ||
98 | + /// It will close as many screens as you define. Times must be> 0; | ||
99 | + static close(int times) { | ||
100 | + if ((times == null) || (times < 1)) { | ||
101 | + times = 1; | ||
102 | + } | ||
103 | + int count = 0; | ||
104 | + var back = key.currentState.popUntil((route) { | ||
105 | + return count++ == times; | ||
106 | + }); | ||
107 | + return back; | ||
108 | + } | ||
109 | + | ||
86 | /// It replaces Navigator.pushReplacement, but needs no context, and it doesn't have the Navigator.pushReplacement | 110 | /// It replaces Navigator.pushReplacement, but needs no context, and it doesn't have the Navigator.pushReplacement |
87 | /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior | 111 | /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior |
88 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. | 112 | /// of rebuilding every app after a route, use rebuildRoutes = true as the parameter. |
@@ -90,7 +114,7 @@ class Get { | @@ -90,7 +114,7 @@ class Get { | ||
90 | {bool rebuildRoutes = false, | 114 | {bool rebuildRoutes = false, |
91 | Transition transition = Transition.rightToLeft}) { | 115 | Transition transition = Transition.rightToLeft}) { |
92 | return key.currentState.pushReplacement( | 116 | return key.currentState.pushReplacement( |
93 | - GetRoute(opaque: rebuildRoutes, child: page, transition: transition)); | 117 | + GetRoute(opaque: rebuildRoutes, page: page, transition: transition)); |
94 | } | 118 | } |
95 | 119 | ||
96 | /// It replaces Navigator.pushAndRemoveUntil, but needs no context | 120 | /// It replaces Navigator.pushAndRemoveUntil, but needs no context |
@@ -98,7 +122,7 @@ class Get { | @@ -98,7 +122,7 @@ class Get { | ||
98 | {bool rebuildRoutes = false, | 122 | {bool rebuildRoutes = false, |
99 | Transition transition = Transition.rightToLeft}) { | 123 | Transition transition = Transition.rightToLeft}) { |
100 | return key.currentState.pushAndRemoveUntil( | 124 | return key.currentState.pushAndRemoveUntil( |
101 | - GetRoute(opaque: rebuildRoutes, child: page, transition: transition), | 125 | + GetRoute(opaque: rebuildRoutes, page: page, transition: transition), |
102 | predicate); | 126 | predicate); |
103 | } | 127 | } |
104 | 128 | ||
@@ -189,28 +213,89 @@ class Get { | @@ -189,28 +213,89 @@ class Get { | ||
189 | } | 213 | } |
190 | 214 | ||
191 | static snackbar(title, message, | 215 | static snackbar(title, message, |
192 | - {Color colorText, Duration duration, SnackPosition snackPosition, Color backgroundColor}) { | 216 | + {Color colorText, |
217 | + Duration duration, | ||
218 | + SnackPosition snackPosition, | ||
219 | + Widget titleText, | ||
220 | + Widget messageText, | ||
221 | + Widget icon, | ||
222 | + bool shouldIconPulse, | ||
223 | + double maxWidth, | ||
224 | + EdgeInsets margin, | ||
225 | + EdgeInsets padding, | ||
226 | + double borderRadius, | ||
227 | + Color borderColor, | ||
228 | + double borderWidth, | ||
229 | + Color backgroundColor, | ||
230 | + Color leftBarIndicatorColor, | ||
231 | + List<BoxShadow> boxShadows, | ||
232 | + Gradient backgroundGradient, | ||
233 | + FlatButton mainButton, | ||
234 | + OnTap onTap, | ||
235 | + bool isDismissible, | ||
236 | + bool showProgressIndicator, | ||
237 | + SnackDismissDirection dismissDirection, | ||
238 | + AnimationController progressIndicatorController, | ||
239 | + Color progressIndicatorBackgroundColor, | ||
240 | + Animation<Color> progressIndicatorValueColor, | ||
241 | + SnackStyle snackStyle, | ||
242 | + Curve forwardAnimationCurve, | ||
243 | + Curve reverseAnimationCurve, | ||
244 | + Duration animationDuration, | ||
245 | + double barBlur, | ||
246 | + double overlayBlur, | ||
247 | + Color overlayColor, | ||
248 | + Form userInputForm}) { | ||
249 | + // if (key.currentState.mounted) | ||
193 | return GetBar( | 250 | return GetBar( |
194 | - titleText: Text( | ||
195 | - title, | ||
196 | - style: TextStyle( | ||
197 | - color: colorText ?? Theme.of(Get.key.currentContext).accentColor, | ||
198 | - fontWeight: FontWeight.w800, | ||
199 | - fontSize: 16), | ||
200 | - ), | ||
201 | - messageText: Text( | ||
202 | - message, | ||
203 | - style: TextStyle( | ||
204 | - color: colorText ?? Theme.of(Get.key.currentContext).accentColor, | ||
205 | - fontWeight: FontWeight.w300, | ||
206 | - fontSize: 14), | ||
207 | - ), | ||
208 | - snackPosition: snackPosition ?? SnackPosition.TOP, | ||
209 | - borderRadius: 15, | ||
210 | - margin: EdgeInsets.symmetric(horizontal: 10), | ||
211 | - duration: duration ?? Duration(seconds: 3), | ||
212 | - barBlur: 7.0, | ||
213 | - backgroundColor: ( backgroundColor ?? Colors.grey.withOpacity(0.2) ), | ||
214 | - )..show(); | 251 | + titleText: titleText ?? |
252 | + Text( | ||
253 | + title, | ||
254 | + style: TextStyle( | ||
255 | + color: | ||
256 | + colorText ?? Theme.of(Get.key.currentContext).accentColor, | ||
257 | + fontWeight: FontWeight.w800, | ||
258 | + fontSize: 16), | ||
259 | + ), | ||
260 | + messageText: messageText ?? | ||
261 | + Text( | ||
262 | + message, | ||
263 | + style: TextStyle( | ||
264 | + color: | ||
265 | + colorText ?? Theme.of(Get.key.currentContext).accentColor, | ||
266 | + fontWeight: FontWeight.w300, | ||
267 | + fontSize: 14), | ||
268 | + ), | ||
269 | + snackPosition: snackPosition ?? SnackPosition.TOP, | ||
270 | + borderRadius: borderRadius ?? 15, | ||
271 | + margin: margin ?? EdgeInsets.symmetric(horizontal: 10), | ||
272 | + duration: duration ?? Duration(seconds: 3), | ||
273 | + barBlur: barBlur ?? 7.0, | ||
274 | + backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2), | ||
275 | + icon: icon, | ||
276 | + shouldIconPulse: shouldIconPulse ?? true, | ||
277 | + maxWidth: maxWidth, | ||
278 | + padding: padding ?? EdgeInsets.all(16), | ||
279 | + borderColor: borderColor, | ||
280 | + borderWidth: borderWidth, | ||
281 | + leftBarIndicatorColor: leftBarIndicatorColor, | ||
282 | + boxShadows: boxShadows, | ||
283 | + backgroundGradient: backgroundGradient, | ||
284 | + mainButton: mainButton, | ||
285 | + onTap: onTap, | ||
286 | + isDismissible: isDismissible ?? true, | ||
287 | + dismissDirection: dismissDirection ?? SnackDismissDirection.VERTICAL, | ||
288 | + showProgressIndicator: showProgressIndicator ?? false, | ||
289 | + progressIndicatorController: progressIndicatorController, | ||
290 | + progressIndicatorBackgroundColor: progressIndicatorBackgroundColor, | ||
291 | + progressIndicatorValueColor: progressIndicatorValueColor, | ||
292 | + snackStyle: snackStyle ?? SnackStyle.FLOATING, | ||
293 | + forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc, | ||
294 | + reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc, | ||
295 | + animationDuration: animationDuration ?? Duration(seconds: 1), | ||
296 | + overlayBlur: overlayBlur ?? 0.0, | ||
297 | + overlayColor: overlayColor ?? Colors.transparent, | ||
298 | + userInputForm: userInputForm) | ||
299 | + ..show(); | ||
215 | } | 300 | } |
216 | } | 301 | } |
1 | name: get | 1 | name: get |
2 | -description: A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars with no context. | ||
3 | -version: 1.7.1 | 2 | +description: A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars easily with no context. |
3 | +version: 1.8.1 | ||
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