jonataslaw

added Get.config - added LogEnable/disable - added default transition - added ov…

…erlayContext - added default popGesture behaviour - fix Duration transition
@@ -178,7 +178,14 @@ @@ -178,7 +178,14 @@
178 - Improve performance 178 - Improve performance
179 - Decrease lib size to 94.9kb (25.4k after compiled on release) 179 - Decrease lib size to 94.9kb (25.4k after compiled on release)
180 180
181 -  
182 -  
183 - 181 +## [1.14.1-dev]
  182 +- Fix ternary on new dart version
  183 +
  184 +## [1.16.0-dev]
  185 +- Added Get config
  186 +- Added logEnable
  187 +- Added Default transition
  188 +- Added default popGesture behaviour
  189 +- Added overlayContext
  190 +- Fix Duration transition
184 191
@@ -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/beta branch of Flutter, use the version 1.14.0-dev. 14 +##### If you use master/dev branch of Flutter, use the version 1.16.0-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.6 // or ^1.14.0-dev 22 + get: ^1.12.0 // ^1.16.0-dev on dev/master
23 ``` 23 ```
24 24
25 And import it: 25 And import it:
@@ -95,6 +95,7 @@ but with Get, all you have to do is call your Get.snackbar from anywhere in your @@ -95,6 +95,7 @@ but with Get, all you have to do is call your Get.snackbar from anywhere in your
95 duration: Duration(seconds: 3), 95 duration: Duration(seconds: 3),
96 ); 96 );
97 97
  98 +
98 ////////// ALL FEATURES ////////// 99 ////////// ALL FEATURES //////////
99 // Color colorText, 100 // Color colorText,
100 // Duration duration, 101 // Duration duration,
@@ -130,6 +131,8 @@ but with Get, all you have to do is call your Get.snackbar from anywhere in your @@ -130,6 +131,8 @@ but with Get, all you have to do is call your Get.snackbar from anywhere in your
130 // Form userInputForm 131 // Form userInputForm
131 /////////////////////////////////// 132 ///////////////////////////////////
132 ``` 133 ```
  134 +If you prefer the traditional snackbar, or want to customize it from scratch, including adding just one line (Get.snackbar makes use of a mandatory title and message), you can use GetBar (). Show () which provides the RAW API on which Get.snackbar was built.
  135 +
133 ### Dialogs 136 ### Dialogs
134 137
135 To open dialog: 138 To open dialog:
@@ -179,19 +182,17 @@ Get.bottomSheet( @@ -179,19 +182,17 @@ Get.bottomSheet(
179 } 182 }
180 ); 183 );
181 ``` 184 ```
  185 +### Global configurations
  186 +You can create Global settings for Get. Just add Get.config to your code before pushing any route
182 187
183 -### Do you use another function that depends on the context? Get can give you the context of the current screen too!  
184 -Use Get.context rather context  
185 -  
186 -- Note: this does not work with certain InheritedWidgets.  
187 -99% of the cases, this will work well, but if Get.context doesn't work, it means that you are trying to use widgets that should be on your tree, outside of it. Get.context will work for ALL cases where it is appropriate.  
188 -  
189 -  
190 -### That's it, you've learned how to navigate between routes the default way.  
191 -  
192 -However, for people who like more organized code who want to navigate with named routes, or for Flutter_web Developers who want the url to show exactly which route is being shown, and want the page refresh not to affect the state of the routes. On your site, we give you a much more elegant and functional solution. Yeah, the default navigation doesn't fully support Flutter_web, but Get does !!!! 188 +```dart
  189 +Get.config(
  190 + enableLog = true,
  191 + defaultPopGesture = true,
  192 + defaultTransition = Transitions.cupertino}
  193 +```
193 194
194 -## So... Is possible used default namedRoutes from flutter? 195 +## Navigate with named routes:
195 - Yes, and with no navigation bug, add "named" to Get. HOWEVER, TO MAKE THIS TYPE OF NAVIGATION, USE THE ROUTE MODEL FROM REPOSITORY. 196 - Yes, and with no navigation bug, add "named" to Get. HOWEVER, TO MAKE THIS TYPE OF NAVIGATION, USE THE ROUTE MODEL FROM REPOSITORY.
196 Example of navigation with named routes: 197 Example of navigation with named routes:
197 198
@@ -43,7 +43,7 @@ Future<T> getShowGeneralDialog<T>({ @@ -43,7 +43,7 @@ Future<T> getShowGeneralDialog<T>({
43 assert(!barrierDismissible || barrierLabel != null); 43 assert(!barrierDismissible || barrierLabel != null);
44 return Get.key.currentState.push<T>(_DialogRoute<T>( 44 return Get.key.currentState.push<T>(_DialogRoute<T>(
45 pageBuilder: pageBuilder, 45 pageBuilder: pageBuilder,
46 - settings: RouteSettings(name: "dialog"), // REMOVE THIS IF ERROR 46 + settings: RouteSettings(name: "dialog"),
47 barrierDismissible: barrierDismissible, 47 barrierDismissible: barrierDismissible,
48 barrierLabel: barrierLabel, 48 barrierLabel: barrierLabel,
49 barrierColor: barrierColor, 49 barrierColor: barrierColor,
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
2 import 'package:flutter/scheduler.dart'; 2 import 'package:flutter/scheduler.dart';
3 import 'package:get/src/dialog/dialog.dart'; 3 import 'package:get/src/dialog/dialog.dart';
4 import 'package:get/get.dart'; 4 import 'package:get/get.dart';
  5 +import '../get.dart';
5 import 'platform/platform.dart'; 6 import 'platform/platform.dart';
6 import 'routes/blur/backdrop_blur.dart'; 7 import 'routes/blur/backdrop_blur.dart';
7 import 'routes/blur/transparent_route.dart'; 8 import 'routes/blur/transparent_route.dart';
@@ -42,6 +43,12 @@ class Get { @@ -42,6 +43,12 @@ class Get {
42 ///the parentheses and the magic will occur. 43 ///the parentheses and the magic will occur.
43 Get._(); 44 Get._();
44 45
  46 + static bool _enableLog = true;
  47 + static bool _defaultPopGesture = GetPlatform.isIOS;
  48 + static bool _defaultOpaqueRoute = true;
  49 + static Transition _defaultTransition =
  50 + (GetPlatform.isIOS ? Transition.cupertino : Transition.fade);
  51 +
45 /// It replaces Navigator.push, but needs no context, and it doesn't have the Navigator.push 52 /// It replaces Navigator.push, but needs no context, and it doesn't have the Navigator.push
46 /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior 53 /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
47 /// of rebuilding every app after a route, use opaque = true as the parameter. 54 /// of rebuilding every app after a route, use opaque = true as the parameter.
@@ -55,11 +62,9 @@ class Get { @@ -55,11 +62,9 @@ class Get {
55 return key.currentState.push(GetRoute( 62 return key.currentState.push(GetRoute(
56 opaque: opaque ?? true, 63 opaque: opaque ?? true,
57 page: page, 64 page: page,
58 - popGesture: popGesture,  
59 - transition: transition ?? GetPlatform.isIOS  
60 - ? Transition.cupertino  
61 - : Transition.fade,  
62 - duration: duration ?? const Duration(milliseconds: 400))); 65 + popGesture: popGesture ?? _defaultPopGesture,
  66 + transition: transition ?? _defaultTransition,
  67 + transitionDuration: duration ?? const Duration(milliseconds: 400)));
63 } 68 }
64 69
65 /// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed 70 /// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed
@@ -144,11 +149,9 @@ class Get { @@ -144,11 +149,9 @@ class Get {
144 return key.currentState.pushReplacement(GetRoute( 149 return key.currentState.pushReplacement(GetRoute(
145 opaque: opaque ?? true, 150 opaque: opaque ?? true,
146 page: page, 151 page: page,
147 - popGesture: popGesture,  
148 - transition: transition ?? GetPlatform.isIOS  
149 - ? Transition.cupertino  
150 - : Transition.fade,  
151 - duration: duration)); 152 + popGesture: popGesture ?? _defaultPopGesture,
  153 + transition: transition ?? _defaultTransition,
  154 + transitionDuration: duration));
152 } 155 }
153 156
154 /// It replaces Navigator.pushAndRemoveUntil, but needs no context 157 /// It replaces Navigator.pushAndRemoveUntil, but needs no context
@@ -161,11 +164,9 @@ class Get { @@ -161,11 +164,9 @@ class Get {
161 return key.currentState.pushAndRemoveUntil( 164 return key.currentState.pushAndRemoveUntil(
162 GetRoute( 165 GetRoute(
163 opaque: opaque ?? true, 166 opaque: opaque ?? true,
164 - popGesture: popGesture, 167 + popGesture: popGesture ?? _defaultPopGesture,
165 page: page, 168 page: page,
166 - transition: transition ?? GetPlatform.isIOS  
167 - ? Transition.cupertino  
168 - : Transition.fade, 169 + transition: transition ?? _defaultTransition,
169 ), 170 ),
170 predicate ?? route); 171 predicate ?? route);
171 } 172 }
@@ -374,13 +375,48 @@ class Get { @@ -374,13 +375,48 @@ class Get {
374 }); 375 });
375 } 376 }
376 377
  378 + /// change default config of Get
  379 + static void config(
  380 + {bool enableLog,
  381 + bool defaultPopGesture,
  382 + bool defaultOpaqueRoute,
  383 + Transition defaultTransition}) {
  384 + if (enableLog != null) {
  385 + _enableLog = enableLog;
  386 + }
  387 + if (defaultPopGesture != null) {
  388 + _defaultPopGesture = defaultPopGesture;
  389 + }
  390 + if (defaultOpaqueRoute != null) {
  391 + _defaultOpaqueRoute = defaultOpaqueRoute;
  392 + }
  393 + if (defaultTransition != null) {
  394 + _defaultTransition = defaultTransition;
  395 + }
  396 + }
  397 +
  398 + static bool get isLogEnable => _enableLog;
  399 + static bool get isPopGestureEnable => _defaultPopGesture;
  400 + static bool get isOpaqueRouteDefault => _defaultOpaqueRoute;
  401 +
  402 + /// give access to currentContext
377 static BuildContext get context => key.currentContext; 403 static BuildContext get context => key.currentContext;
378 404
  405 + static BuildContext get overlayContext => key.currentState.overlay.context;
  406 +
  407 + /// give access to Theme.of(context)
379 static ThemeData get theme => Theme.of(context); 408 static ThemeData get theme => Theme.of(context);
380 409
  410 + /// give access to Theme.of(context).iconTheme.color
381 static Color get iconColor => Theme.of(context).iconTheme.color; 411 static Color get iconColor => Theme.of(context).iconTheme.color;
382 412
  413 + /// give access to MediaQuery.of(context).size.height
383 static double get height => MediaQuery.of(context).size.height; 414 static double get height => MediaQuery.of(context).size.height;
384 415
  416 + /// give access to MediaQuery.of(context).size.width
385 static double get width => MediaQuery.of(context).size.width; 417 static double get width => MediaQuery.of(context).size.width;
386 } 418 }
  419 +
  420 +/// It replaces the Flutter Navigator, but needs no context.
  421 +/// You can to use navigator.push(YourRoute()) rather Navigator.push(context, YourRoute());
  422 +NavigatorState get navigator => Get.key.currentState;
@@ -30,9 +30,10 @@ class GetRoute<T> extends PageRoute<T> { @@ -30,9 +30,10 @@ class GetRoute<T> extends PageRoute<T> {
30 this.curve = Curves.linear, 30 this.curve = Curves.linear,
31 this.alignment, 31 this.alignment,
32 this.opaque = true, 32 this.opaque = true,
  33 + this.transitionDuration = const Duration(milliseconds: 400),
33 this.popGesture, 34 this.popGesture,
34 this.transition = Transition.cupertino, 35 this.transition = Transition.cupertino,
35 - this.duration = const Duration(milliseconds: 400), 36 + // this.duration = const Duration(milliseconds: 400),
36 bool fullscreenDialog = false, 37 bool fullscreenDialog = false,
37 }) : assert(page != null), 38 }) : assert(page != null),
38 assert(maintainState != null), 39 assert(maintainState != null),
@@ -45,7 +46,7 @@ class GetRoute<T> extends PageRoute<T> { @@ -45,7 +46,7 @@ class GetRoute<T> extends PageRoute<T> {
45 46
46 final bool popGesture; 47 final bool popGesture;
47 48
48 - final Duration duration; 49 + // final Duration duration;
49 50
50 final String title; 51 final String title;
51 52
@@ -99,8 +100,7 @@ class GetRoute<T> extends PageRoute<T> { @@ -99,8 +100,7 @@ class GetRoute<T> extends PageRoute<T> {
99 final bool opaque; 100 final bool opaque;
100 101
101 @override 102 @override
102 - // A relatively rigorous eyeball estimation.  
103 - Duration get transitionDuration => const Duration(milliseconds: 400); 103 + final Duration transitionDuration;
104 104
105 @override 105 @override
106 Color get barrierColor => null; //Color(0x00FFFFFF); 106 Color get barrierColor => null; //Color(0x00FFFFFF);
@@ -230,6 +230,7 @@ class GetRoute<T> extends PageRoute<T> { @@ -230,6 +230,7 @@ class GetRoute<T> extends PageRoute<T> {
230 Animation<double> secondaryAnimation, 230 Animation<double> secondaryAnimation,
231 Widget child, 231 Widget child,
232 Transition transition, 232 Transition transition,
  233 + Duration duration,
233 Curve curve, 234 Curve curve,
234 Alignment alignment, 235 Alignment alignment,
235 ) { 236 ) {
@@ -468,6 +469,7 @@ class GetRoute<T> extends PageRoute<T> { @@ -468,6 +469,7 @@ class GetRoute<T> extends PageRoute<T> {
468 secondaryAnimation, 469 secondaryAnimation,
469 child, 470 child,
470 transition, 471 transition,
  472 + transitionDuration,
471 curve, 473 curve,
472 alignment); 474 alignment);
473 } 475 }
1 import 'package:flutter/widgets.dart'; 1 import 'package:flutter/widgets.dart';
2 2
  3 +import '../../get_main.dart';
  4 +
3 class Routing { 5 class Routing {
4 final current; 6 final current;
5 final previous; 7 final previous;
@@ -29,13 +31,13 @@ class GetObserver extends NavigatorObserver { @@ -29,13 +31,13 @@ class GetObserver extends NavigatorObserver {
29 @override 31 @override
30 void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { 32 void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
31 if ('${route?.settings?.name}' == 'snackbar') { 33 if ('${route?.settings?.name}' == 'snackbar') {
32 - print("[OPEN SNACKBAR] ${route?.settings?.name}"); 34 + if (Get.isLogEnable) print("[OPEN SNACKBAR] ${route?.settings?.name}");
33 } else if ('${route?.settings?.name}' == 'bottomsheet') { 35 } else if ('${route?.settings?.name}' == 'bottomsheet') {
34 - print("[OPEN BOTTOMSHEET] ${route?.settings?.name}"); 36 + if (Get.isLogEnable) print("[OPEN BOTTOMSHEET] ${route?.settings?.name}");
35 } else if ('${route?.settings?.name}' == 'dialog') { 37 } else if ('${route?.settings?.name}' == 'dialog') {
36 - print("[OPEN DIALOG] ${route?.settings?.name}"); 38 + if (Get.isLogEnable) print("[OPEN DIALOG] ${route?.settings?.name}");
37 } else { 39 } else {
38 - print("[GOING TO ROUTE] ${route?.settings?.name}"); 40 + if (Get.isLogEnable) print("[GOING TO ROUTE] ${route?.settings?.name}");
39 } 41 }
40 42
41 routing(Routing( 43 routing(Routing(
@@ -53,15 +55,16 @@ class GetObserver extends NavigatorObserver { @@ -53,15 +55,16 @@ class GetObserver extends NavigatorObserver {
53 super.didPop(route, previousRoute); 55 super.didPop(route, previousRoute);
54 56
55 if ('${route?.settings?.name}' == 'snackbar') { 57 if ('${route?.settings?.name}' == 'snackbar') {
56 - print("[CLOSE SNACKBAR] ${route?.settings?.name}"); 58 + if (Get.isLogEnable) print("[CLOSE SNACKBAR] ${route?.settings?.name}");
57 } else if ('${route?.settings?.name}' == 'bottomsheet') { 59 } else if ('${route?.settings?.name}' == 'bottomsheet') {
  60 + if (Get.isLogEnable)
58 print("[CLOSE BOTTOMSHEET] ${route?.settings?.name}"); 61 print("[CLOSE BOTTOMSHEET] ${route?.settings?.name}");
59 } else if ('${route?.settings?.name}' == 'dialog') { 62 } else if ('${route?.settings?.name}' == 'dialog') {
60 - print("[CLOSE DIALOG] ${route?.settings?.name}"); 63 + if (Get.isLogEnable) print("[CLOSE DIALOG] ${route?.settings?.name}");
61 } else if ('${route?.settings?.name}' == 'snackbar') { 64 } else if ('${route?.settings?.name}' == 'snackbar') {
62 - print("[CLOSE SNACKBAR] ${route?.settings?.name}"); 65 + if (Get.isLogEnable) print("[CLOSE SNACKBAR] ${route?.settings?.name}");
63 } else { 66 } else {
64 - print("[BACK ROUTE] ${route?.settings?.name}"); 67 + if (Get.isLogEnable) print("[BACK ROUTE] ${route?.settings?.name}");
65 } 68 }
66 69
67 routing(Routing( 70 routing(Routing(
@@ -77,7 +80,7 @@ class GetObserver extends NavigatorObserver { @@ -77,7 +80,7 @@ class GetObserver extends NavigatorObserver {
77 @override 80 @override
78 void didReplace({Route newRoute, Route oldRoute}) { 81 void didReplace({Route newRoute, Route oldRoute}) {
79 super.didReplace(newRoute: newRoute, oldRoute: oldRoute); 82 super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
80 - print("[REPLACE ROUTE] ${oldRoute?.settings?.name}"); 83 + if (Get.isLogEnable) print("[REPLACE ROUTE] ${oldRoute?.settings?.name}");
81 84
82 routing(Routing( 85 routing(Routing(
83 removed: null, // add '${oldRoute?.settings?.name}' or remain null ??? 86 removed: null, // add '${oldRoute?.settings?.name}' or remain null ???
@@ -92,7 +95,7 @@ class GetObserver extends NavigatorObserver { @@ -92,7 +95,7 @@ class GetObserver extends NavigatorObserver {
92 @override 95 @override
93 void didRemove(Route route, Route previousRoute) { 96 void didRemove(Route route, Route previousRoute) {
94 super.didRemove(route, previousRoute); 97 super.didRemove(route, previousRoute);
95 - print("[REMOVING ROUTE] ${route?.settings?.name}"); 98 + if (Get.isLogEnable) print("[REMOVING ROUTE] ${route?.settings?.name}");
96 99
97 routing(Routing( 100 routing(Routing(
98 isBack: false, 101 isBack: false,
1 name: get 1 name: get
2 description: Navigate between screens, display snackbars, dialogs and bottomSheets, from anywhere in your code without context with Get. 2 description: Navigate between screens, display snackbars, dialogs and bottomSheets, from anywhere in your code without context with Get.
3 -version: 1.14.0-dev 3 +version: 1.16.0-dev
4 homepage: https://github.com/jonataslaw/get 4 homepage: https://github.com/jonataslaw/get
5 5
6 environment: 6 environment: