Jonny Borges
Committed by GitHub

release new version

... ... @@ -98,8 +98,24 @@
- Added customs transitions
- Improve dialogs performance
## [1.7.1]
## [1.7.1]
-Fix docs
## [1.7.2]
-Fix bottomsheet on macos
## [1.7.3]
-Added transitions docs
## [1.7.4]
-Fix dialog child error
## [1.8.0]
-Add Get.close method.
-Add many Snackbars features
## [1.8.1]
-Fix new snackbar features
... ...
... ... @@ -3,7 +3,7 @@
A consistent navigation library that lets you navigate between screens, open dialogs/bottomSheets, and display snackbars from anywhere in your code without context.
## Getting Started
Flutter's conventional navigation has a lot of unnecessary boilerplate, requires context to navigate between screens, open dialogs, and snacking is really painful.
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.
In addition, with each route navigation, all of your screens below MaterialApp are rebuilt, often causing RAM and CPU bottlenecks.
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.
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:
```
dependencies:
get: ^1.7.4
get: ^1.8.1
```
And import it:
... ... @@ -69,11 +69,7 @@ ex:
```dart
if(data == 'sucess') madeAnything();
```
### Others methods (docs will be added soon):
Get.removeRoute // remove one route.
Get.until // back repeatedly until the predicate returns true.
Get.offUntil // go to next route and remove all the previous routes until the predicate returns true.
Get.offNamedUntil // go to next named route and remove all the previous routes until the predicate returns true.
### SnackBars
To show a modern snackbar:
... ... @@ -81,20 +77,54 @@ To show a modern snackbar:
Get.snackbar('Hi', 'i am a modern snackbar');
```
To have a simple SnackBar with Flutter, you must get the context of Scaffold, or you must use a GlobalKey attached to your Scaffold,
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!
but with Get, all you have to do is call your Get.snackbar from anywhere in your code or customize it however you want!
```dart
GetBar(
title: "Hey i'm a Get SnackBar!",
message:
"It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!",
icon: Icon(Icons.alarm),
Get.snackbar(
"Hey i'm a Get SnackBar!", // title
"It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!", // message
icon: Icon(Icons.alarm),
shouldIconPulse: true,
onTap:(){},
barBlur: 20,
isDismissible: true,
duration: Duration(seconds: 3),
)..show();
);
////////// ALL FEATURES //////////
// Color colorText,
// Duration duration,
// SnackPosition snackPosition,
// Widget titleText,
// Widget messageText,
// Widget icon,
// bool shouldIconPulse,
// double maxWidth,
// EdgeInsets margin,
// EdgeInsets padding,
// double borderRadius,
// Color borderColor,
// double borderWidth,
// Color backgroundColor,
// Color leftBarIndicatorColor,
// List<BoxShadow> boxShadows,
// Gradient backgroundGradient,
// FlatButton mainButton,
// OnTap onTap,
// bool isDismissible,
// bool showProgressIndicator,
// AnimationController progressIndicatorController,
// Color progressIndicatorBackgroundColor,
// Animation<Color> progressIndicatorValueColor,
// SnackStyle snackStyle,
// Curve forwardAnimationCurve,
// Curve reverseAnimationCurve,
// Duration animationDuration,
// double barBlur,
// double overlayBlur,
// Color overlayColor,
// Form userInputForm
///////////////////////////////////
```
### Dialogs
... ... @@ -183,15 +213,10 @@ void main() {
}
```
### Important!!! COPY THE ROUTER CLASS BELOW:
### COPY THE ROUTER CLASS BELOW:
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.
We suggest that you copy this class for 3 reasons:
1- You must define an escape route if you accidentally set a wrong route. This example already contains this.
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!
3- These routes are designed to work with GetRoute, not CupertinoPageRoute or MaterialPageRoute. Never put them here.
#### Important!!!
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.
```dart
class Router {
... ... @@ -199,18 +224,18 @@ class Router {
switch (settings.name) {
case '/':
return GetRoute(
builder: (_) => SplashScreen(),
page: SplashScreen(),
settings: settings,
);
case '/Home':
return GetRoute(settings: settings, builder: (_) => Home(), transition: Transition.fade);
return GetRoute(settings: settings, page: Home(), transition: Transition.fade);
case '/Chat':
return GetRoute(settings: settings, builder: (_) => Chat(),transition: Transition.rightToLeft);
return GetRoute(settings: settings, page: Chat(), transition: Transition.rightToLeft);
default:
return GetRoute(
settings: settings,
transition: Transition.rotate
builder: (_) => Scaffold(
transition: Transition.fade,
page: Scaffold(
body: Center(
child: Text('No route defined for ${settings.name}')),
));
... ... @@ -229,12 +254,7 @@ class FirstRoute extends StatelessWidget {
leading: IconButton(
icon: Icon(Icons.add),
onPressed: () {
GetBar(
title: "Hey i'm a Get SnackBar!",
message:
"It's unbelievable! I'm using SnackBar without context, without boilerplate, without Scaffold, it is something truly amazing!",
duration: Duration(seconds: 3),
)..show();
Get.snackbar("hi", "i am a modern snackbar");
},
),
title: Text('First Route'),
... ... @@ -271,4 +291,16 @@ class SecondRoute extends StatelessWidget {
}
```
### Others methods (docs will be added soon):
```dart
Get.removeRoute() // remove one route.
Get.until() // back repeatedly until the predicate returns true.
Get.offUntil() // go to next route and remove all the previous routes until the predicate returns true.
Get.offNamedUntil() // go to next named route and remove all the previous routes until the predicate returns true.
```
That is all.
... ...
... ... @@ -46,3 +46,31 @@ class SecondRoute extends StatelessWidget {
);
}
}
class Router {
static Route<dynamic> generateRoute(RouteSettings settings) {
switch (settings.name) {
case '/':
return GetRoute(
page: SplashScreen(),
settings: settings,
);
case '/Home':
return GetRoute(
settings: settings, page: Home(), transition: Transition.fade);
case '/Chat':
return GetRoute(
settings: settings,
page: Chat(),
transition: Transition.rightToLeft);
default:
return GetRoute(
settings: settings,
transition: Transition.rotate,
page: Scaffold(
body:
Center(child: Text('No route defined for ${settings.name}')),
));
}
}
}
... ...
... ... @@ -63,7 +63,7 @@ packages:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
version: "0.1.3"
flutter:
dependency: "direct main"
description: flutter
... ... @@ -80,7 +80,7 @@ packages:
name: get
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.8.0"
image:
dependency: transitive
description:
... ...
... ... @@ -108,15 +108,12 @@ class _GetModalBottomSheet<T> extends StatefulWidget {
class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
String _getRouteLabel(MaterialLocalizations localizations) {
switch (Theme.of(context).platform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return '';
case TargetPlatform.android:
case TargetPlatform.fuchsia:
return localizations.dialogLabel;
if ((Theme.of(context).platform == TargetPlatform.android) ||
(Theme.of(context).platform == TargetPlatform.fuchsia)) {
return localizations.dialogLabel;
} else {
return '';
}
return null;
}
@override
... ...
... ... @@ -9,13 +9,13 @@ class GetRoute<T> extends PageRouteBuilder<T> {
RouteSettings settings,
this.opaque = false,
this.maintainState = true,
@required this.child,
@required this.transition,
@required this.page,
this.transition = Transition.fade,
this.curve = Curves.linear,
this.alignment,
this.duration = const Duration(milliseconds: 300),
this.duration = const Duration(milliseconds: 400),
bool fullscreenDialog = false,
}) : assert(child != null),
}) : assert(page != null),
assert(maintainState != null),
assert(fullscreenDialog != null),
assert(opaque != null),
... ... @@ -23,7 +23,7 @@ class GetRoute<T> extends PageRouteBuilder<T> {
fullscreenDialog: fullscreenDialog,
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return child;
return page;
},
transitionDuration: duration,
settings: settings,
... ... @@ -114,10 +114,10 @@ class GetRoute<T> extends PageRouteBuilder<T> {
);
break;
case Transition.rotate:
return new RotationTransition(
return RotationTransition(
alignment: alignment,
turns: animation,
child: new ScaleTransition(
child: ScaleTransition(
alignment: alignment,
scale: animation,
child: FadeTransition(
... ... @@ -211,7 +211,7 @@ class GetRoute<T> extends PageRouteBuilder<T> {
@override
String get debugLabel => '${super.debugLabel}(${settings.name})';
final Widget child;
final Widget page;
final Transition transition;
... ...
... ... @@ -32,34 +32,46 @@ class Get {
/// of rebuilding every app after a route, use rebuildRoutes = true as the parameter.
static to(Widget page,
{bool rebuildRoutes = false, Transition transition = Transition.fade}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return key.currentState.push(
GetRoute(opaque: rebuildRoutes, child: page, transition: transition));
GetRoute(opaque: rebuildRoutes, page: page, transition: transition));
}
/// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed
/// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
/// of rebuilding every app after a route, use rebuildRoutes = true as the parameter.
static toNamed(String page, {arguments}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return key.currentState.pushNamed(page, arguments: arguments);
}
/// It replaces Navigator.pushReplacementNamed, but needs no context.
static offNamed(String page, {arguments}) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return key.currentState.pushReplacementNamed(page, arguments: arguments);
}
/// It replaces Navigator.popUntil, but needs no context.
static until(String page, predicate) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return key.currentState.popUntil(predicate);
}
/// It replaces Navigator.pushAndRemoveUntil, but needs no context.
static offUntil(page, predicate) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return key.currentState.pushAndRemoveUntil(page, predicate);
}
/// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context.
static offNamedUntil(page, predicate) {
// if (key.currentState.mounted) // add this if appear problems on future with route navigate
// when widget don't mounted
return key.currentState.pushNamedAndRemoveUntil(page, predicate);
}
... ... @@ -83,6 +95,18 @@ class Get {
return key.currentState.pop(result);
}
/// It will close as many screens as you define. Times must be> 0;
static close(int times) {
if ((times == null) || (times < 1)) {
times = 1;
}
int count = 0;
var back = key.currentState.popUntil((route) {
return count++ == times;
});
return back;
}
/// It replaces Navigator.pushReplacement, but needs no context, and it doesn't have the Navigator.pushReplacement
/// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
/// of rebuilding every app after a route, use rebuildRoutes = true as the parameter.
... ... @@ -90,7 +114,7 @@ class Get {
{bool rebuildRoutes = false,
Transition transition = Transition.rightToLeft}) {
return key.currentState.pushReplacement(
GetRoute(opaque: rebuildRoutes, child: page, transition: transition));
GetRoute(opaque: rebuildRoutes, page: page, transition: transition));
}
/// It replaces Navigator.pushAndRemoveUntil, but needs no context
... ... @@ -98,7 +122,7 @@ class Get {
{bool rebuildRoutes = false,
Transition transition = Transition.rightToLeft}) {
return key.currentState.pushAndRemoveUntil(
GetRoute(opaque: rebuildRoutes, child: page, transition: transition),
GetRoute(opaque: rebuildRoutes, page: page, transition: transition),
predicate);
}
... ... @@ -189,28 +213,89 @@ class Get {
}
static snackbar(title, message,
{Color colorText, Duration duration, SnackPosition snackPosition, Color backgroundColor}) {
{Color colorText,
Duration duration,
SnackPosition snackPosition,
Widget titleText,
Widget messageText,
Widget icon,
bool shouldIconPulse,
double maxWidth,
EdgeInsets margin,
EdgeInsets padding,
double borderRadius,
Color borderColor,
double borderWidth,
Color backgroundColor,
Color leftBarIndicatorColor,
List<BoxShadow> boxShadows,
Gradient backgroundGradient,
FlatButton mainButton,
OnTap onTap,
bool isDismissible,
bool showProgressIndicator,
SnackDismissDirection dismissDirection,
AnimationController progressIndicatorController,
Color progressIndicatorBackgroundColor,
Animation<Color> progressIndicatorValueColor,
SnackStyle snackStyle,
Curve forwardAnimationCurve,
Curve reverseAnimationCurve,
Duration animationDuration,
double barBlur,
double overlayBlur,
Color overlayColor,
Form userInputForm}) {
// if (key.currentState.mounted)
return GetBar(
titleText: Text(
title,
style: TextStyle(
color: colorText ?? Theme.of(Get.key.currentContext).accentColor,
fontWeight: FontWeight.w800,
fontSize: 16),
),
messageText: Text(
message,
style: TextStyle(
color: colorText ?? Theme.of(Get.key.currentContext).accentColor,
fontWeight: FontWeight.w300,
fontSize: 14),
),
snackPosition: snackPosition ?? SnackPosition.TOP,
borderRadius: 15,
margin: EdgeInsets.symmetric(horizontal: 10),
duration: duration ?? Duration(seconds: 3),
barBlur: 7.0,
backgroundColor: ( backgroundColor ?? Colors.grey.withOpacity(0.2) ),
)..show();
titleText: titleText ??
Text(
title,
style: TextStyle(
color:
colorText ?? Theme.of(Get.key.currentContext).accentColor,
fontWeight: FontWeight.w800,
fontSize: 16),
),
messageText: messageText ??
Text(
message,
style: TextStyle(
color:
colorText ?? Theme.of(Get.key.currentContext).accentColor,
fontWeight: FontWeight.w300,
fontSize: 14),
),
snackPosition: snackPosition ?? SnackPosition.TOP,
borderRadius: borderRadius ?? 15,
margin: margin ?? EdgeInsets.symmetric(horizontal: 10),
duration: duration ?? Duration(seconds: 3),
barBlur: barBlur ?? 7.0,
backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2),
icon: icon,
shouldIconPulse: shouldIconPulse ?? true,
maxWidth: maxWidth,
padding: padding ?? EdgeInsets.all(16),
borderColor: borderColor,
borderWidth: borderWidth,
leftBarIndicatorColor: leftBarIndicatorColor,
boxShadows: boxShadows,
backgroundGradient: backgroundGradient,
mainButton: mainButton,
onTap: onTap,
isDismissible: isDismissible ?? true,
dismissDirection: dismissDirection ?? SnackDismissDirection.VERTICAL,
showProgressIndicator: showProgressIndicator ?? false,
progressIndicatorController: progressIndicatorController,
progressIndicatorBackgroundColor: progressIndicatorBackgroundColor,
progressIndicatorValueColor: progressIndicatorValueColor,
snackStyle: snackStyle ?? SnackStyle.FLOATING,
forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc,
reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc,
animationDuration: animationDuration ?? Duration(seconds: 1),
overlayBlur: overlayBlur ?? 0.0,
overlayColor: overlayColor ?? Colors.transparent,
userInputForm: userInputForm)
..show();
}
}
... ...
name: get
description: A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars with no context.
version: 1.7.1
description: A consistent navigation library that lets you navigate between screens, open dialogs, and display snackbars easily with no context.
version: 1.8.1
homepage: https://github.com/jonataslaw/get
environment:
... ...