Jonny Borges
Committed by GitHub

New release of Get

@@ -201,3 +201,10 @@ @@ -201,3 +201,10 @@
201 201
202 ## [1.19.0-dev] 202 ## [1.19.0-dev]
203 - Added nested navigators 203 - Added nested navigators
  204 +
  205 +## [1.19.1-dev]
  206 +- Fix default transitions for namedRoutes
  207 +
  208 +## [1.20.0-dev]
  209 +- Added Get Instance Manager
  210 + Get.put / Get.find / Get.delete
@@ -22,7 +22,7 @@ Navigator.of(context).push( @@ -22,7 +22,7 @@ Navigator.of(context).push(
22 Get.to(Home()); 22 Get.to(Home());
23 ``` 23 ```
24 24
25 -##### If you use master/dev/beta branch of Flutter, use the version 1.19.1-dev. 25 +##### If you use master/dev/beta branch of Flutter, use the version 1.20.0-dev.
26 * If you use MODULAR, add on your MaterialApp this: navigatorKey: Get.addKey(Modular.navigatorKey) 26 * If you use MODULAR, add on your MaterialApp this: navigatorKey: Get.addKey(Modular.navigatorKey)
27 27
28 ## How to use? 28 ## How to use?
@@ -31,7 +31,7 @@ Add this to your package's pubspec.yaml file: @@ -31,7 +31,7 @@ Add this to your package's pubspec.yaml file:
31 31
32 ``` 32 ```
33 dependencies: 33 dependencies:
34 - get: ^1.16.0 // ^1.19.1-dev on beta/dev/master 34 + get: ^1.17.0 // ^1.20.0-dev on beta/dev/master
35 ``` 35 ```
36 36
37 And import it: 37 And import it:
@@ -250,6 +250,30 @@ Get.config( @@ -250,6 +250,30 @@ Get.config(
250 defaultTransition = Transitions.cupertino} 250 defaultTransition = Transitions.cupertino}
251 ``` 251 ```
252 252
  253 +## Simple Instance Manager
  254 +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.
  255 +
  256 +
  257 +```dart
  258 +Controller controller = Get.put(Controller()); // Rather Controller controller = Controller();
  259 +```
  260 +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.
  261 +So you can use your controller (or class Bloc) normally
  262 +
  263 +```dart
  264 +controller.fetchApi();// Rather Controller controller = Controller();
  265 +```
  266 +
  267 +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:
  268 +
  269 +```dart
  270 +Controller controller = Get.find(Controller());
  271 +```
  272 +And then you will be able to recover your controller data that was obtained back there:
  273 +
  274 +```dart
  275 +Text(controller.textFromApi);
  276 +```
253 277
254 ## Navigate with named routes: 278 ## Navigate with named routes:
255 - Yes, and with no navigation bug, add "named" to Get. HOWEVER, TO MAKE THIS TYPE OF NAVIGATION, USE THE ROUTE MODEL FROM REPOSITORY. 279 - 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'; @@ -4,8 +4,6 @@ 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 '../get.dart';
6 import 'platform/platform.dart'; 6 import 'platform/platform.dart';
7 -import 'routes/blur/backdrop_blur.dart';  
8 -import 'routes/blur/transparent_route.dart';  
9 import 'routes/default_route.dart'; 7 import 'routes/default_route.dart';
10 8
11 class Get { 9 class Get {
@@ -331,36 +329,6 @@ class Get { @@ -331,36 +329,6 @@ class Get {
331 )); 329 ));
332 } 330 }
333 331
334 - // /// get arguments from current screen. You need of context  
335 - // @deprecated  
336 - // static args(context) {  
337 - // return ModalRoute.of(context).settings.arguments;  
338 - // }  
339 -  
340 - static Future backdrop(Widget child,  
341 - {double radius = 20.0,  
342 - double blurRadius: 20.0,  
343 - int duration = 300,  
344 - Transition transition = Transition.fade,  
345 - Widget bottomButton = const Icon(Icons.visibility),  
346 - double bottomHeight = 60.0,  
347 - bool bottomButtonRotate = false}) {  
348 - final page = RippleBackdropAnimatePage(  
349 - child: child,  
350 - childFade: true,  
351 - duration: duration,  
352 - blurRadius: blurRadius,  
353 - bottomButton: bottomButton,  
354 - bottomHeight: bottomHeight,  
355 - bottomButtonRotate: bottomButtonRotate,  
356 - );  
357 -  
358 - return key.currentState  
359 - .push(TransparentRoute(builder: (BuildContext context) {  
360 - return page;  
361 - }));  
362 - }  
363 -  
364 static void snackbar(title, message, 332 static void snackbar(title, message,
365 {Color colorText, 333 {Color colorText,
366 Duration duration, 334 Duration duration,
@@ -483,6 +451,32 @@ class Get { @@ -483,6 +451,32 @@ class Get {
483 return recoverKey; 451 return recoverKey;
484 } 452 }
485 453
  454 + static Map<dynamic, dynamic> _singl = {};
  455 +
  456 + /// Register a singleton instance of your class
  457 + static T put<T>(T singleton) {
  458 + _singl.putIfAbsent(T, () => singleton);
  459 + return _singl[T];
  460 + }
  461 +
  462 + /// Delete a singleton instance of your class
  463 + static bool delete<T>(T singleton) {
  464 + if (!_singl.containsKey(T)) {
  465 + throw 'key id not found';
  466 + }
  467 + _singl.removeWhere((oldkey, value) => (oldkey == T));
  468 + return true;
  469 + }
  470 +
  471 + /// Recover a singleton instance of your class
  472 + static T find<T>(T key) {
  473 + if (!_singl.containsKey(T)) {
  474 + throw 'key id not found';
  475 + }
  476 + final recoverKey = _singl[T];
  477 + return recoverKey;
  478 + }
  479 +
486 /// give access to Routing API from GetObserver 480 /// give access to Routing API from GetObserver
487 static Routing get routing => _routing; 481 static Routing get routing => _routing;
488 482
@@ -525,6 +519,8 @@ class Get { @@ -525,6 +519,8 @@ class Get {
525 /// check if default opaque route is enable 519 /// check if default opaque route is enable
526 static bool get isOpaqueRouteDefault => _defaultOpaqueRoute; 520 static bool get isOpaqueRouteDefault => _defaultOpaqueRoute;
527 521
  522 + static Transition get defaultTransition => _defaultTransition;
  523 +
528 /// give access to currentContext 524 /// give access to currentContext
529 static BuildContext get context => key.currentContext; 525 static BuildContext get context => key.currentContext;
530 526
@@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart'; @@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart';
5 import 'package:flutter/foundation.dart'; 5 import 'package:flutter/foundation.dart';
6 import 'package:flutter/gestures.dart'; 6 import 'package:flutter/gestures.dart';
7 import 'package:flutter/material.dart'; 7 import 'package:flutter/material.dart';
  8 +import 'package:get/src/get_main.dart';
8 9
9 import '../platform/platform.dart'; 10 import '../platform/platform.dart';
10 import 'transitions_type.dart'; 11 import 'transitions_type.dart';
@@ -32,7 +33,7 @@ class GetRoute<T> extends PageRoute<T> { @@ -32,7 +33,7 @@ class GetRoute<T> extends PageRoute<T> {
32 this.opaque = true, 33 this.opaque = true,
33 this.transitionDuration = const Duration(milliseconds: 400), 34 this.transitionDuration = const Duration(milliseconds: 400),
34 this.popGesture, 35 this.popGesture,
35 - this.transition = Transition.cupertino, 36 + this.transition,
36 // this.duration = const Duration(milliseconds: 400), 37 // this.duration = const Duration(milliseconds: 400),
37 bool fullscreenDialog = false, 38 bool fullscreenDialog = false,
38 }) : assert(page != null), 39 }) : assert(page != null),
@@ -229,11 +230,13 @@ class GetRoute<T> extends PageRoute<T> { @@ -229,11 +230,13 @@ class GetRoute<T> extends PageRoute<T> {
229 Animation<double> animation, 230 Animation<double> animation,
230 Animation<double> secondaryAnimation, 231 Animation<double> secondaryAnimation,
231 Widget child, 232 Widget child,
232 - Transition transition, 233 + Transition tr,
233 Duration duration, 234 Duration duration,
234 Curve curve, 235 Curve curve,
235 Alignment alignment, 236 Alignment alignment,
236 ) { 237 ) {
  238 + Transition transition = (tr ?? Get.defaultTransition);
  239 +
237 if (route.fullscreenDialog) { 240 if (route.fullscreenDialog) {
238 final bool linearTransition = isPopGestureInProgress(route); 241 final bool linearTransition = isPopGestureInProgress(route);
239 return CupertinoFullscreenDialogTransition( 242 return CupertinoFullscreenDialogTransition(
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.19.0-dev 3 +version: 1.20.0-dev
4 homepage: https://github.com/jonataslaw/get 4 homepage: https://github.com/jonataslaw/get
5 5
6 environment: 6 environment: