jonataslaw

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

…erlayContext - added default popGesture behaviour - fix Duration transition
... ... @@ -178,7 +178,14 @@
- Improve performance
- Decrease lib size to 94.9kb (25.4k after compiled on release)
## [1.14.1-dev]
- Fix ternary on new dart version
## [1.16.0-dev]
- Added Get config
- Added logEnable
- Added Default transition
- Added default popGesture behaviour
- Added overlayContext
- Fix Duration transition
... ...
... ... @@ -11,7 +11,7 @@ increasing your productivity, and eliminating all the bugs present in Flutter's
##### If you use MODULAR, add on your MaterialApp this: navigatorKey: Get.addKey(Modular.navigatorKey)
##### If you use master/dev/beta branch of Flutter, use the version 1.14.0-dev.
##### If you use master/dev branch of Flutter, use the version 1.16.0-dev.
## How to use?
... ... @@ -19,7 +19,7 @@ Add this to your package's pubspec.yaml file:
```
dependencies:
get: ^1.11.6 // or ^1.14.0-dev
get: ^1.12.0 // ^1.16.0-dev on dev/master
```
And import it:
... ... @@ -95,6 +95,7 @@ but with Get, all you have to do is call your Get.snackbar from anywhere in your
duration: Duration(seconds: 3),
);
////////// ALL FEATURES //////////
// Color colorText,
// Duration duration,
... ... @@ -130,6 +131,8 @@ but with Get, all you have to do is call your Get.snackbar from anywhere in your
// Form userInputForm
///////////////////////////////////
```
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.
### Dialogs
To open dialog:
... ... @@ -179,19 +182,17 @@ Get.bottomSheet(
}
);
```
### Global configurations
You can create Global settings for Get. Just add Get.config to your code before pushing any route
### Do you use another function that depends on the context? Get can give you the context of the current screen too!
Use Get.context rather context
- Note: this does not work with certain InheritedWidgets.
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.
### That's it, you've learned how to navigate between routes the default way.
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 !!!!
```dart
Get.config(
enableLog = true,
defaultPopGesture = true,
defaultTransition = Transitions.cupertino}
```
## So... Is possible used default namedRoutes from flutter?
## Navigate with named routes:
- Yes, and with no navigation bug, add "named" to Get. HOWEVER, TO MAKE THIS TYPE OF NAVIGATION, USE THE ROUTE MODEL FROM REPOSITORY.
Example of navigation with named routes:
... ...
... ... @@ -43,7 +43,7 @@ Future<T> getShowGeneralDialog<T>({
assert(!barrierDismissible || barrierLabel != null);
return Get.key.currentState.push<T>(_DialogRoute<T>(
pageBuilder: pageBuilder,
settings: RouteSettings(name: "dialog"), // REMOVE THIS IF ERROR
settings: RouteSettings(name: "dialog"),
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel,
barrierColor: barrierColor,
... ...
... ... @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/src/dialog/dialog.dart';
import 'package:get/get.dart';
import '../get.dart';
import 'platform/platform.dart';
import 'routes/blur/backdrop_blur.dart';
import 'routes/blur/transparent_route.dart';
... ... @@ -42,6 +43,12 @@ class Get {
///the parentheses and the magic will occur.
Get._();
static bool _enableLog = true;
static bool _defaultPopGesture = GetPlatform.isIOS;
static bool _defaultOpaqueRoute = true;
static Transition _defaultTransition =
(GetPlatform.isIOS ? Transition.cupertino : Transition.fade);
/// It replaces Navigator.push, but needs no context, and it doesn't have the Navigator.push
/// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
/// of rebuilding every app after a route, use opaque = true as the parameter.
... ... @@ -55,11 +62,9 @@ class Get {
return key.currentState.push(GetRoute(
opaque: opaque ?? true,
page: page,
popGesture: popGesture,
transition: transition ?? GetPlatform.isIOS
? Transition.cupertino
: Transition.fade,
duration: duration ?? const Duration(milliseconds: 400)));
popGesture: popGesture ?? _defaultPopGesture,
transition: transition ?? _defaultTransition,
transitionDuration: duration ?? const Duration(milliseconds: 400)));
}
/// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed
... ... @@ -144,11 +149,9 @@ class Get {
return key.currentState.pushReplacement(GetRoute(
opaque: opaque ?? true,
page: page,
popGesture: popGesture,
transition: transition ?? GetPlatform.isIOS
? Transition.cupertino
: Transition.fade,
duration: duration));
popGesture: popGesture ?? _defaultPopGesture,
transition: transition ?? _defaultTransition,
transitionDuration: duration));
}
/// It replaces Navigator.pushAndRemoveUntil, but needs no context
... ... @@ -161,11 +164,9 @@ class Get {
return key.currentState.pushAndRemoveUntil(
GetRoute(
opaque: opaque ?? true,
popGesture: popGesture,
popGesture: popGesture ?? _defaultPopGesture,
page: page,
transition: transition ?? GetPlatform.isIOS
? Transition.cupertino
: Transition.fade,
transition: transition ?? _defaultTransition,
),
predicate ?? route);
}
... ... @@ -374,13 +375,48 @@ class Get {
});
}
/// change default config of Get
static void config(
{bool enableLog,
bool defaultPopGesture,
bool defaultOpaqueRoute,
Transition defaultTransition}) {
if (enableLog != null) {
_enableLog = enableLog;
}
if (defaultPopGesture != null) {
_defaultPopGesture = defaultPopGesture;
}
if (defaultOpaqueRoute != null) {
_defaultOpaqueRoute = defaultOpaqueRoute;
}
if (defaultTransition != null) {
_defaultTransition = defaultTransition;
}
}
static bool get isLogEnable => _enableLog;
static bool get isPopGestureEnable => _defaultPopGesture;
static bool get isOpaqueRouteDefault => _defaultOpaqueRoute;
/// give access to currentContext
static BuildContext get context => key.currentContext;
static BuildContext get overlayContext => key.currentState.overlay.context;
/// give access to Theme.of(context)
static ThemeData get theme => Theme.of(context);
/// give access to Theme.of(context).iconTheme.color
static Color get iconColor => Theme.of(context).iconTheme.color;
/// give access to MediaQuery.of(context).size.height
static double get height => MediaQuery.of(context).size.height;
/// give access to MediaQuery.of(context).size.width
static double get width => MediaQuery.of(context).size.width;
}
/// It replaces the Flutter Navigator, but needs no context.
/// You can to use navigator.push(YourRoute()) rather Navigator.push(context, YourRoute());
NavigatorState get navigator => Get.key.currentState;
... ...
... ... @@ -30,9 +30,10 @@ class GetRoute<T> extends PageRoute<T> {
this.curve = Curves.linear,
this.alignment,
this.opaque = true,
this.transitionDuration = const Duration(milliseconds: 400),
this.popGesture,
this.transition = Transition.cupertino,
this.duration = const Duration(milliseconds: 400),
// this.duration = const Duration(milliseconds: 400),
bool fullscreenDialog = false,
}) : assert(page != null),
assert(maintainState != null),
... ... @@ -45,7 +46,7 @@ class GetRoute<T> extends PageRoute<T> {
final bool popGesture;
final Duration duration;
// final Duration duration;
final String title;
... ... @@ -99,8 +100,7 @@ class GetRoute<T> extends PageRoute<T> {
final bool opaque;
@override
// A relatively rigorous eyeball estimation.
Duration get transitionDuration => const Duration(milliseconds: 400);
final Duration transitionDuration;
@override
Color get barrierColor => null; //Color(0x00FFFFFF);
... ... @@ -230,6 +230,7 @@ class GetRoute<T> extends PageRoute<T> {
Animation<double> secondaryAnimation,
Widget child,
Transition transition,
Duration duration,
Curve curve,
Alignment alignment,
) {
... ... @@ -468,6 +469,7 @@ class GetRoute<T> extends PageRoute<T> {
secondaryAnimation,
child,
transition,
transitionDuration,
curve,
alignment);
}
... ...
import 'package:flutter/widgets.dart';
import '../../get_main.dart';
class Routing {
final current;
final previous;
... ... @@ -29,13 +31,13 @@ class GetObserver extends NavigatorObserver {
@override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
if ('${route?.settings?.name}' == 'snackbar') {
print("[OPEN SNACKBAR] ${route?.settings?.name}");
if (Get.isLogEnable) print("[OPEN SNACKBAR] ${route?.settings?.name}");
} else if ('${route?.settings?.name}' == 'bottomsheet') {
print("[OPEN BOTTOMSHEET] ${route?.settings?.name}");
if (Get.isLogEnable) print("[OPEN BOTTOMSHEET] ${route?.settings?.name}");
} else if ('${route?.settings?.name}' == 'dialog') {
print("[OPEN DIALOG] ${route?.settings?.name}");
if (Get.isLogEnable) print("[OPEN DIALOG] ${route?.settings?.name}");
} else {
print("[GOING TO ROUTE] ${route?.settings?.name}");
if (Get.isLogEnable) print("[GOING TO ROUTE] ${route?.settings?.name}");
}
routing(Routing(
... ... @@ -53,15 +55,16 @@ class GetObserver extends NavigatorObserver {
super.didPop(route, previousRoute);
if ('${route?.settings?.name}' == 'snackbar') {
print("[CLOSE SNACKBAR] ${route?.settings?.name}");
if (Get.isLogEnable) print("[CLOSE SNACKBAR] ${route?.settings?.name}");
} else if ('${route?.settings?.name}' == 'bottomsheet') {
print("[CLOSE BOTTOMSHEET] ${route?.settings?.name}");
if (Get.isLogEnable)
print("[CLOSE BOTTOMSHEET] ${route?.settings?.name}");
} else if ('${route?.settings?.name}' == 'dialog') {
print("[CLOSE DIALOG] ${route?.settings?.name}");
if (Get.isLogEnable) print("[CLOSE DIALOG] ${route?.settings?.name}");
} else if ('${route?.settings?.name}' == 'snackbar') {
print("[CLOSE SNACKBAR] ${route?.settings?.name}");
if (Get.isLogEnable) print("[CLOSE SNACKBAR] ${route?.settings?.name}");
} else {
print("[BACK ROUTE] ${route?.settings?.name}");
if (Get.isLogEnable) print("[BACK ROUTE] ${route?.settings?.name}");
}
routing(Routing(
... ... @@ -77,7 +80,7 @@ class GetObserver extends NavigatorObserver {
@override
void didReplace({Route newRoute, Route oldRoute}) {
super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
print("[REPLACE ROUTE] ${oldRoute?.settings?.name}");
if (Get.isLogEnable) print("[REPLACE ROUTE] ${oldRoute?.settings?.name}");
routing(Routing(
removed: null, // add '${oldRoute?.settings?.name}' or remain null ???
... ... @@ -92,7 +95,7 @@ class GetObserver extends NavigatorObserver {
@override
void didRemove(Route route, Route previousRoute) {
super.didRemove(route, previousRoute);
print("[REMOVING ROUTE] ${route?.settings?.name}");
if (Get.isLogEnable) print("[REMOVING ROUTE] ${route?.settings?.name}");
routing(Routing(
isBack: false,
... ...
name: get
description: Navigate between screens, display snackbars, dialogs and bottomSheets, from anywhere in your code without context with Get.
version: 1.14.0-dev
version: 1.16.0-dev
homepage: https://github.com/jonataslaw/get
environment:
... ...