Jonny Borges
Committed by GitHub

New release of Get

... ... @@ -201,3 +201,10 @@
## [1.19.0-dev]
- Added nested navigators
## [1.19.1-dev]
- Fix default transitions for namedRoutes
## [1.20.0-dev]
- Added Get Instance Manager
Get.put / Get.find / Get.delete
\ No newline at end of file
... ...
... ... @@ -22,7 +22,7 @@ Navigator.of(context).push(
Get.to(Home());
```
##### If you use master/dev/beta branch of Flutter, use the version 1.19.1-dev.
##### If you use master/dev/beta branch of Flutter, use the version 1.20.0-dev.
* If you use MODULAR, add on your MaterialApp this: navigatorKey: Get.addKey(Modular.navigatorKey)
## How to use?
... ... @@ -31,7 +31,7 @@ Add this to your package's pubspec.yaml file:
```
dependencies:
get: ^1.16.0 // ^1.19.1-dev on beta/dev/master
get: ^1.17.0 // ^1.20.0-dev on beta/dev/master
```
And import it:
... ... @@ -250,6 +250,30 @@ Get.config(
defaultTransition = Transitions.cupertino}
```
## Simple Instance Manager
Are you already using Get and want to make your project as lean as possible? Now Get has a simple manager that allows you to retrieve the same class as your Bloc or Controller with just 1 lines of code.
```dart
Controller controller = Get.put(Controller()); // Rather Controller controller = Controller();
```
Instead of instantiating your class within the class you are using, you are instantiating it within the Get instance, which will make it available throughout your App.
So you can use your controller (or class Bloc) normally
```dart
controller.fetchApi();// Rather Controller controller = Controller();
```
Imagine that you have navigated through numerous routes, and you need a data that was left behind in your controller, you would need a state manager combined with the Provider or Get_it, correct? Not with Get. You just need to ask Get to "search" for your controller, you don't need any additional dependencies:
```dart
Controller controller = Get.find(Controller());
```
And then you will be able to recover your controller data that was obtained back there:
```dart
Text(controller.textFromApi);
```
## 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.
... ...
... ... @@ -4,8 +4,6 @@ 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';
import 'routes/default_route.dart';
class Get {
... ... @@ -331,36 +329,6 @@ class Get {
));
}
// /// get arguments from current screen. You need of context
// @deprecated
// static args(context) {
// return ModalRoute.of(context).settings.arguments;
// }
static Future backdrop(Widget child,
{double radius = 20.0,
double blurRadius: 20.0,
int duration = 300,
Transition transition = Transition.fade,
Widget bottomButton = const Icon(Icons.visibility),
double bottomHeight = 60.0,
bool bottomButtonRotate = false}) {
final page = RippleBackdropAnimatePage(
child: child,
childFade: true,
duration: duration,
blurRadius: blurRadius,
bottomButton: bottomButton,
bottomHeight: bottomHeight,
bottomButtonRotate: bottomButtonRotate,
);
return key.currentState
.push(TransparentRoute(builder: (BuildContext context) {
return page;
}));
}
static void snackbar(title, message,
{Color colorText,
Duration duration,
... ... @@ -483,6 +451,32 @@ class Get {
return recoverKey;
}
static Map<dynamic, dynamic> _singl = {};
/// Register a singleton instance of your class
static T put<T>(T singleton) {
_singl.putIfAbsent(T, () => singleton);
return _singl[T];
}
/// Delete a singleton instance of your class
static bool delete<T>(T singleton) {
if (!_singl.containsKey(T)) {
throw 'key id not found';
}
_singl.removeWhere((oldkey, value) => (oldkey == T));
return true;
}
/// Recover a singleton instance of your class
static T find<T>(T key) {
if (!_singl.containsKey(T)) {
throw 'key id not found';
}
final recoverKey = _singl[T];
return recoverKey;
}
/// give access to Routing API from GetObserver
static Routing get routing => _routing;
... ... @@ -525,6 +519,8 @@ class Get {
/// check if default opaque route is enable
static bool get isOpaqueRouteDefault => _defaultOpaqueRoute;
static Transition get defaultTransition => _defaultTransition;
/// give access to currentContext
static BuildContext get context => key.currentContext;
... ...
... ... @@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:get/src/get_main.dart';
import '../platform/platform.dart';
import 'transitions_type.dart';
... ... @@ -32,7 +33,7 @@ class GetRoute<T> extends PageRoute<T> {
this.opaque = true,
this.transitionDuration = const Duration(milliseconds: 400),
this.popGesture,
this.transition = Transition.cupertino,
this.transition,
// this.duration = const Duration(milliseconds: 400),
bool fullscreenDialog = false,
}) : assert(page != null),
... ... @@ -229,11 +230,13 @@ class GetRoute<T> extends PageRoute<T> {
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child,
Transition transition,
Transition tr,
Duration duration,
Curve curve,
Alignment alignment,
) {
Transition transition = (tr ?? Get.defaultTransition);
if (route.fullscreenDialog) {
final bool linearTransition = isPopGestureInProgress(route);
return CupertinoFullscreenDialogTransition(
... ...
name: get
description: Navigate between screens, display snackbars, dialogs and bottomSheets, from anywhere in your code without context with Get.
version: 1.19.0-dev
version: 1.20.0-dev
homepage: https://github.com/jonataslaw/get
environment:
... ...