Jonatas

update to 3.5.0

  1 +## [3.5.0]
  2 +- Added logwritter (@stefandevo)
  3 +- Added responsiveValue (@juanjoseleca)
  4 +- Fixed ghost url for snackbar, bottomsheets, and dialogs and unnamed navigation.
  5 +
1 ## [3.4.6] 6 ## [3.4.6]
2 - Fix TextField dispose throw on last Flutter hotfix 7 - Fix TextField dispose throw on last Flutter hotfix
3 8
@@ -7,6 +12,7 @@ @@ -7,6 +12,7 @@
7 12
8 ## [3.4.4] 13 ## [3.4.4]
9 - Fix exception 'isInit called null' when tags are used in conjunction with dependencies. (@djade007) 14 - Fix exception 'isInit called null' when tags are used in conjunction with dependencies. (@djade007)
  15 +- Fix typos (@tiagocpeixoto)
10 16
11 ## [3.4.3] 17 ## [3.4.3]
12 - Fix onInit fired only first time 18 - Fix onInit fired only first time
@@ -16,7 +16,6 @@ import '../../utils.dart'; @@ -16,7 +16,6 @@ import '../../utils.dart';
16 abstract class GetInterface { 16 abstract class GetInterface {
17 bool defaultPopGesture = GetPlatform.isIOS; 17 bool defaultPopGesture = GetPlatform.isIOS;
18 bool defaultOpaqueRoute = true; 18 bool defaultOpaqueRoute = true;
19 - bool forceRouteName = true;  
20 Transition defaultTransition; 19 Transition defaultTransition;
21 Duration defaultDurationTransition = Duration(milliseconds: 400); 20 Duration defaultDurationTransition = Duration(milliseconds: 400);
22 bool defaultGlobalState = true; 21 bool defaultGlobalState = true;
1 import 'package:get/src/core/log.dart'; 1 import 'package:get/src/core/log.dart';
2 import 'package:get/src/navigation/root/smart_management.dart'; 2 import 'package:get/src/navigation/root/smart_management.dart';
3 import 'package:get/src/state_manager/rx/rx_interface.dart'; 3 import 'package:get/src/state_manager/rx/rx_interface.dart';
  4 +import 'package:get/src/utils/queue/get_queue.dart';
4 5
5 class GetConfig { 6 class GetConfig {
6 static SmartManagement smartManagement = SmartManagement.full; 7 static SmartManagement smartManagement = SmartManagement.full;
@@ -196,6 +197,14 @@ class GetInstance { @@ -196,6 +197,14 @@ class GetInstance {
196 return true; 197 return true;
197 } 198 }
198 199
  200 + static GetQueue queue = GetQueue();
  201 +
  202 + // Future<bool> delete<S>({String tag, String key, bool force = false}) async {
  203 + // final s = await queue
  204 + // .add<bool>(() async => dele<S>(tag: tag, key: key, force: force));
  205 + // return s;
  206 + // }
  207 +
199 /// Delete class instance on [S] and clean memory 208 /// Delete class instance on [S] and clean memory
200 Future<bool> delete<S>({String tag, String key, bool force = false}) async { 209 Future<bool> delete<S>({String tag, String key, bool force = false}) async {
201 String newKey; 210 String newKey;
@@ -205,8 +214,10 @@ class GetInstance { @@ -205,8 +214,10 @@ class GetInstance {
205 newKey = key; 214 newKey = key;
206 } 215 }
207 216
  217 + return queue.add<bool>(() async {
208 if (!_singl.containsKey(newKey)) { 218 if (!_singl.containsKey(newKey)) {
209 - GetConfig.log('Instance $newKey not found', isError: true); 219 + GetConfig.log('[GETX] Instance $newKey already been removed.',
  220 + isError: true);
210 return false; 221 return false;
211 } 222 }
212 223
@@ -235,6 +246,7 @@ class GetInstance { @@ -235,6 +246,7 @@ class GetInstance {
235 } 246 }
236 // _routesKey?.remove(key); 247 // _routesKey?.remove(key);
237 return true; 248 return true;
  249 + });
238 } 250 }
239 251
240 /// check if instance is registered 252 /// check if instance is registered
@@ -16,6 +16,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -16,6 +16,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
16 @required this.isScrollControlled, 16 @required this.isScrollControlled,
17 RouteSettings settings, 17 RouteSettings settings,
18 }) : assert(isScrollControlled != null), 18 }) : assert(isScrollControlled != null),
  19 + name = "BOTTOMSHEET: ${builder.hashCode}",
19 assert(isDismissible != null), 20 assert(isDismissible != null),
20 assert(enableDrag != null), 21 assert(enableDrag != null),
21 super(settings: settings); 22 super(settings: settings);
@@ -30,6 +31,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -30,6 +31,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
30 final Color modalBarrierColor; 31 final Color modalBarrierColor;
31 final bool isDismissible; 32 final bool isDismissible;
32 final bool enableDrag; 33 final bool enableDrag;
  34 + final String name;
33 35
34 // remove safearea from top 36 // remove safearea from top
35 final bool removeTop; 37 final bool removeTop;
  1 +import 'package:flutter/widgets.dart';
  2 +
  3 +import '../../../instance_manager.dart';
  4 +import '../../../route_manager.dart';
  5 +
  6 +class GetDialogRoute<T> extends PopupRoute<T> {
  7 + GetDialogRoute({
  8 + @required RoutePageBuilder pageBuilder,
  9 + bool barrierDismissible = true,
  10 + String barrierLabel,
  11 + Color barrierColor = const Color(0x80000000),
  12 + Duration transitionDuration = const Duration(milliseconds: 200),
  13 + RouteTransitionsBuilder transitionBuilder,
  14 + RouteSettings settings,
  15 + }) : assert(barrierDismissible != null),
  16 + widget = pageBuilder,
  17 + name = "DIALOG: ${pageBuilder.hashCode}",
  18 + _barrierDismissible = barrierDismissible,
  19 + _barrierLabel = barrierLabel,
  20 + _barrierColor = barrierColor,
  21 + _transitionDuration = transitionDuration,
  22 + _transitionBuilder = transitionBuilder,
  23 + super(settings: settings);
  24 +
  25 + final RoutePageBuilder widget;
  26 +
  27 + @override
  28 + bool get barrierDismissible => _barrierDismissible;
  29 + final bool _barrierDismissible;
  30 +
  31 + final String name;
  32 +
  33 + @override
  34 + void dispose() {
  35 + if (GetConfig.smartManagement != SmartManagement.onlyBuilder) {
  36 + WidgetsBinding.instance.addPostFrameCallback(
  37 + (_) => GetInstance().removeDependencyByRoute(name));
  38 + }
  39 + super.dispose();
  40 + }
  41 +
  42 + @override
  43 + String get barrierLabel => _barrierLabel;
  44 + final String _barrierLabel;
  45 +
  46 + @override
  47 + Color get barrierColor => _barrierColor;
  48 + final Color _barrierColor;
  49 +
  50 + @override
  51 + Duration get transitionDuration => _transitionDuration;
  52 + final Duration _transitionDuration;
  53 +
  54 + final RouteTransitionsBuilder _transitionBuilder;
  55 +
  56 + @override
  57 + Widget buildPage(BuildContext context, Animation<double> animation,
  58 + Animation<double> secondaryAnimation) {
  59 + return Semantics(
  60 + child: widget(context, animation, secondaryAnimation),
  61 + scopesRoute: true,
  62 + explicitChildNodes: true,
  63 + );
  64 + }
  65 +
  66 + @override
  67 + Widget buildTransitions(BuildContext context, Animation<double> animation,
  68 + Animation<double> secondaryAnimation, Widget child) {
  69 + if (_transitionBuilder == null) {
  70 + return FadeTransition(
  71 + opacity: CurvedAnimation(
  72 + parent: animation,
  73 + curve: Curves.linear,
  74 + ),
  75 + child: child);
  76 + } // Some default transition
  77 + return _transitionBuilder(context, animation, secondaryAnimation, child);
  78 + }
  79 +}
@@ -4,6 +4,7 @@ import 'package:get/src/core/get_interface.dart'; @@ -4,6 +4,7 @@ import 'package:get/src/core/get_interface.dart';
4 import 'package:get/instance_manager.dart'; 4 import 'package:get/instance_manager.dart';
5 import 'package:get/route_manager.dart'; 5 import 'package:get/route_manager.dart';
6 import 'package:get/src/core/log.dart'; 6 import 'package:get/src/core/log.dart';
  7 +import 'dialog/dialog_route.dart';
7 import 'root/parse_route.dart'; 8 import 'root/parse_route.dart';
8 import 'routes/bindings_interface.dart'; 9 import 'routes/bindings_interface.dart';
9 10
@@ -46,17 +47,17 @@ extension GetNavigation on GetInterface { @@ -46,17 +47,17 @@ extension GetNavigation on GetInterface {
46 bool preventDuplicates = true, 47 bool preventDuplicates = true,
47 bool popGesture, 48 bool popGesture,
48 }) { 49 }) {
49 - if (preventDuplicates &&  
50 - '/${page.runtimeType}' == currentRoute &&  
51 - forceRouteName) { 50 + String routename = "/${page.runtimeType.toString()}";
  51 + if (preventDuplicates && routename == currentRoute) {
52 return null; 52 return null;
53 } 53 }
54 return global(id).currentState.push( 54 return global(id).currentState.push(
55 GetPageRoute( 55 GetPageRoute(
56 opaque: opaque ?? true, 56 opaque: opaque ?? true,
57 page: () => page, 57 page: () => page,
  58 + routeName: routename,
58 settings: RouteSettings( 59 settings: RouteSettings(
59 - name: forceRouteName ? '/${page.runtimeType}' : '', 60 + // name: forceRouteName ? '${a.runtimeType}' : '',
60 arguments: arguments, 61 arguments: arguments,
61 ), 62 ),
62 popGesture: popGesture ?? defaultPopGesture, 63 popGesture: popGesture ?? defaultPopGesture,
@@ -320,18 +321,16 @@ extension GetNavigation on GetInterface { @@ -320,18 +321,16 @@ extension GetNavigation on GetInterface {
320 preventDuplicates = true, 321 preventDuplicates = true,
321 Duration duration, 322 Duration duration,
322 }) { 323 }) {
323 - if (preventDuplicates &&  
324 - '/${page.runtimeType}' == currentRoute &&  
325 - forceRouteName) { 324 + String routename = "/${page.runtimeType.toString()}";
  325 + if (preventDuplicates && routename == currentRoute) {
326 return null; 326 return null;
327 } 327 }
328 return global(id).currentState.pushReplacement(GetPageRoute( 328 return global(id).currentState.pushReplacement(GetPageRoute(
329 opaque: opaque ?? true, 329 opaque: opaque ?? true,
330 page: () => page, 330 page: () => page,
331 binding: binding, 331 binding: binding,
332 - settings: RouteSettings(  
333 - name: forceRouteName ? '/${page.runtimeType}' : '',  
334 - arguments: arguments), 332 + settings: RouteSettings(arguments: arguments),
  333 + routeName: routename,
335 fullscreenDialog: fullscreenDialog, 334 fullscreenDialog: fullscreenDialog,
336 popGesture: popGesture ?? defaultPopGesture, 335 popGesture: popGesture ?? defaultPopGesture,
337 transition: transition ?? defaultTransition, 336 transition: transition ?? defaultTransition,
@@ -380,16 +379,17 @@ extension GetNavigation on GetInterface { @@ -380,16 +379,17 @@ extension GetNavigation on GetInterface {
380 }) { 379 }) {
381 var route = (Route<dynamic> rota) => false; 380 var route = (Route<dynamic> rota) => false;
382 381
  382 + String routename = "/${page.runtimeType.toString()}";
  383 +
383 return global(id).currentState.pushAndRemoveUntil( 384 return global(id).currentState.pushAndRemoveUntil(
384 GetPageRoute( 385 GetPageRoute(
385 opaque: opaque ?? true, 386 opaque: opaque ?? true,
386 popGesture: popGesture ?? defaultPopGesture, 387 popGesture: popGesture ?? defaultPopGesture,
387 page: () => page, 388 page: () => page,
388 binding: binding, 389 binding: binding,
389 - settings: RouteSettings(  
390 - name: forceRouteName ? '/${page.runtimeType}' : '',  
391 - arguments: arguments), 390 + settings: RouteSettings(arguments: arguments),
392 fullscreenDialog: fullscreenDialog, 391 fullscreenDialog: fullscreenDialog,
  392 + routeName: routename,
393 transition: transition ?? defaultTransition, 393 transition: transition ?? defaultTransition,
394 transitionDuration: duration ?? defaultDurationTransition, 394 transitionDuration: duration ?? defaultDurationTransition,
395 ), 395 ),
@@ -398,44 +398,76 @@ extension GetNavigation on GetInterface { @@ -398,44 +398,76 @@ extension GetNavigation on GetInterface {
398 398
399 /// Show a dialog 399 /// Show a dialog
400 Future<T> dialog<T>( 400 Future<T> dialog<T>(
401 - Widget child, { 401 + Widget widget, {
402 bool barrierDismissible = true, 402 bool barrierDismissible = true,
  403 + Color barrierColor,
  404 + bool useSafeArea = true,
403 bool useRootNavigator = true, 405 bool useRootNavigator = true,
404 - // RouteSettings routeSettings 406 + RouteSettings routeSettings,
405 }) { 407 }) {
406 - return showDialog( 408 + assert(widget != null);
  409 + assert(barrierDismissible != null);
  410 + assert(useSafeArea != null);
  411 + assert(useRootNavigator != null);
  412 + assert(debugCheckHasMaterialLocalizations(context));
  413 +
  414 + final ThemeData theme = Theme.of(context, shadowThemeOnly: true);
  415 + return generalDialog(
  416 + pageBuilder: (BuildContext buildContext, Animation<double> animation,
  417 + Animation<double> secondaryAnimation) {
  418 + final Widget pageChild = widget;
  419 + Widget dialog = Builder(builder: (BuildContext context) {
  420 + return theme != null
  421 + ? Theme(data: theme, child: pageChild)
  422 + : pageChild;
  423 + });
  424 + if (useSafeArea) {
  425 + dialog = SafeArea(child: dialog);
  426 + }
  427 + return dialog;
  428 + },
407 barrierDismissible: barrierDismissible, 429 barrierDismissible: barrierDismissible,
408 - useRootNavigator: useRootNavigator,  
409 - routeSettings: RouteSettings(name: 'dialog'),  
410 - context: overlayContext,  
411 - builder: (_) {  
412 - return child; 430 + barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
  431 + barrierColor: barrierColor ?? Colors.black54,
  432 + transitionDuration: const Duration(milliseconds: 150),
  433 + transitionBuilder: (context, animation, secondaryAnimation, child) {
  434 + return FadeTransition(
  435 + opacity: CurvedAnimation(
  436 + parent: animation,
  437 + curve: Curves.easeOut,
  438 + ),
  439 + child: child,
  440 + );
413 }, 441 },
  442 + useRootNavigator: useRootNavigator,
  443 + routeSettings: routeSettings,
414 ); 444 );
415 } 445 }
416 446
417 /// Api from showGeneralDialog with no context 447 /// Api from showGeneralDialog with no context
418 Future<T> generalDialog<T>({ 448 Future<T> generalDialog<T>({
419 @required RoutePageBuilder pageBuilder, 449 @required RoutePageBuilder pageBuilder,
420 - String barrierLabel = "Dismiss",  
421 - bool barrierDismissible = true, 450 + bool barrierDismissible = false,
  451 + String barrierLabel,
422 Color barrierColor = const Color(0x80000000), 452 Color barrierColor = const Color(0x80000000),
423 Duration transitionDuration = const Duration(milliseconds: 200), 453 Duration transitionDuration = const Duration(milliseconds: 200),
424 RouteTransitionsBuilder transitionBuilder, 454 RouteTransitionsBuilder transitionBuilder,
425 bool useRootNavigator = true, 455 bool useRootNavigator = true,
426 RouteSettings routeSettings, 456 RouteSettings routeSettings,
427 }) { 457 }) {
428 - return showGeneralDialog( 458 + assert(pageBuilder != null);
  459 + assert(useRootNavigator != null);
  460 + assert(!barrierDismissible || barrierLabel != null);
  461 + return Navigator.of(overlayContext, rootNavigator: useRootNavigator)
  462 + .push<T>(GetDialogRoute<T>(
429 pageBuilder: pageBuilder, 463 pageBuilder: pageBuilder,
430 barrierDismissible: barrierDismissible, 464 barrierDismissible: barrierDismissible,
431 barrierLabel: barrierLabel, 465 barrierLabel: barrierLabel,
432 barrierColor: barrierColor, 466 barrierColor: barrierColor,
433 transitionDuration: transitionDuration, 467 transitionDuration: transitionDuration,
434 transitionBuilder: transitionBuilder, 468 transitionBuilder: transitionBuilder,
435 - useRootNavigator: useRootNavigator,  
436 - routeSettings: RouteSettings(name: 'dialog'),  
437 - context: overlayContext,  
438 - ); 469 + settings: routeSettings,
  470 + ));
439 } 471 }
440 472
441 Future<T> defaultDialog<T>({ 473 Future<T> defaultDialog<T>({
@@ -567,7 +599,7 @@ extension GetNavigation on GetInterface { @@ -567,7 +599,7 @@ extension GetNavigation on GetInterface {
567 clipBehavior: clipBehavior, 599 clipBehavior: clipBehavior,
568 isDismissible: isDismissible, 600 isDismissible: isDismissible,
569 modalBarrierColor: barrierColor, 601 modalBarrierColor: barrierColor,
570 - settings: RouteSettings(name: "bottomsheet"), 602 + settings: settings,
571 enableDrag: enableDrag, 603 enableDrag: enableDrag,
572 )); 604 ));
573 } 605 }
@@ -50,7 +50,6 @@ class GetMaterialApp extends StatelessWidget { @@ -50,7 +50,6 @@ class GetMaterialApp extends StatelessWidget {
50 this.defaultTransition, 50 this.defaultTransition,
51 // this.actions, 51 // this.actions,
52 this.getPages, 52 this.getPages,
53 - this.forceRouteName = true,  
54 this.opaqueRoute, 53 this.opaqueRoute,
55 this.enableLog, 54 this.enableLog,
56 this.logWriterCallback, 55 this.logWriterCallback,
@@ -103,7 +102,6 @@ class GetMaterialApp extends StatelessWidget { @@ -103,7 +102,6 @@ class GetMaterialApp extends StatelessWidget {
103 final Function(Routing) routingCallback; 102 final Function(Routing) routingCallback;
104 final Transition defaultTransition; 103 final Transition defaultTransition;
105 final bool opaqueRoute; 104 final bool opaqueRoute;
106 - final bool forceRouteName;  
107 final VoidCallback onInit; 105 final VoidCallback onInit;
108 final VoidCallback onDispose; 106 final VoidCallback onDispose;
109 final bool enableLog; 107 final bool enableLog;
@@ -191,8 +189,6 @@ class GetMaterialApp extends StatelessWidget { @@ -191,8 +189,6 @@ class GetMaterialApp extends StatelessWidget {
191 189
192 if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale; 190 if (fallbackLocale != null) Get.fallbackLocale = fallbackLocale;
193 191
194 - Get.forceRouteName = forceRouteName;  
195 -  
196 if (translations != null) { 192 if (translations != null) {
197 Get.translations = translations.keys; 193 Get.translations = translations.keys;
198 } else if (translationsKeys != null) { 194 } else if (translationsKeys != null) {
@@ -297,6 +293,7 @@ extension Trans on String { @@ -297,6 +293,7 @@ extension Trans on String {
297 Get.translations[Get.fallbackLocale.languageCode].containsKey(this)) { 293 Get.translations[Get.fallbackLocale.languageCode].containsKey(this)) {
298 return Get.translations[Get.fallbackLocale.languageCode][this]; 294 return Get.translations[Get.fallbackLocale.languageCode][this];
299 } 295 }
  296 + return this;
300 } else { 297 } else {
301 return this; 298 return this;
302 } 299 }
@@ -27,6 +27,7 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -27,6 +27,7 @@ class GetPageRoute<T> extends PageRoute<T> {
27 this.barrierColor, 27 this.barrierColor,
28 this.binding, 28 this.binding,
29 this.bindings, 29 this.bindings,
  30 + this.routeName,
30 this.page, 31 this.page,
31 this.barrierLabel, 32 this.barrierLabel,
32 this.maintainState = true, 33 this.maintainState = true,
@@ -42,6 +43,8 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -42,6 +43,8 @@ class GetPageRoute<T> extends PageRoute<T> {
42 43
43 final GetPageBuilder page; 44 final GetPageBuilder page;
44 45
  46 + final String routeName;
  47 +
45 final CustomTransition customTransition; 48 final CustomTransition customTransition;
46 49
47 final Bindings binding; 50 final Bindings binding;
@@ -119,8 +122,9 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -119,8 +122,9 @@ class GetPageRoute<T> extends PageRoute<T> {
119 element.dependencies(); 122 element.dependencies();
120 } 123 }
121 } 124 }
122 - GetConfig.currentRoute = settings.name;  
123 - return page(); 125 + final pageWidget = page();
  126 + GetConfig.currentRoute = settings.name ?? routeName;
  127 + return pageWidget;
124 } 128 }
125 129
126 static bool isPopGestureInProgress(PageRoute<dynamic> route) { 130 static bool isPopGestureInProgress(PageRoute<dynamic> route) {
@@ -389,8 +393,8 @@ class GetPageRoute<T> extends PageRoute<T> { @@ -389,8 +393,8 @@ class GetPageRoute<T> extends PageRoute<T> {
389 @override 393 @override
390 void dispose() { 394 void dispose() {
391 if (GetConfig.smartManagement != SmartManagement.onlyBuilder) { 395 if (GetConfig.smartManagement != SmartManagement.onlyBuilder) {
392 - WidgetsBinding.instance.addPostFrameCallback(  
393 - (_) => GetInstance().removeDependencyByRoute("${settings.name}")); 396 + WidgetsBinding.instance.addPostFrameCallback((_) => GetInstance()
  397 + .removeDependencyByRoute("${settings?.name ?? routeName}"));
394 } 398 }
395 super.dispose(); 399 super.dispose();
396 } 400 }
1 import 'package:flutter/widgets.dart'; 1 import 'package:flutter/widgets.dart';
  2 +import 'package:get/route_manager.dart';
2 import 'package:get/src/instance/get_instance.dart'; 3 import 'package:get/src/instance/get_instance.dart';
  4 +import 'package:get/src/navigation/dialog/dialog_route.dart';
  5 +import 'package:get/src/navigation/routes/default_route.dart';
  6 +import 'package:get/src/navigation/snackbar/snack_route.dart';
3 7
4 class Routing { 8 class Routing {
5 String current; 9 String current;
@@ -25,7 +29,6 @@ class Routing { @@ -25,7 +29,6 @@ class Routing {
25 29
26 void update(void fn(Routing value)) { 30 void update(void fn(Routing value)) {
27 fn(this); 31 fn(this);
28 - GetConfig.currentRoute = this.current;  
29 } 32 }
30 } 33 }
31 34
@@ -46,28 +49,49 @@ class GetObserver extends NavigatorObserver { @@ -46,28 +49,49 @@ class GetObserver extends NavigatorObserver {
46 // String previousArgs; 49 // String previousArgs;
47 String removed; 50 String removed;
48 51
  52 + String name(Route<dynamic> route) {
  53 + if (route?.settings?.name != null) {
  54 + return route?.settings?.name;
  55 + } else if (route is GetPageRoute) {
  56 + return route.routeName;
  57 + } else if (route is GetDialogRoute) {
  58 + return route.name;
  59 + } else if (route is GetModalBottomSheetRoute) {
  60 + return route.name;
  61 + } else {
  62 + return route?.settings?.name;
  63 + }
  64 + }
  65 +
49 @override 66 @override
50 void didPush(Route<dynamic> route, Route<dynamic> previousRoute) { 67 void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
51 - if ('${route?.settings?.name}' == 'snackbar') {  
52 - GetConfig.log("[GETX] OPEN SNACKBAR ${route?.settings?.name}");  
53 - } else if ('${route?.settings?.name}' == 'bottomsheet') {  
54 - GetConfig.log("[GETX] OPEN BOTTOMSHEET ${route?.settings?.name}");  
55 - } else if ('${route?.settings?.name}' == 'dialog') {  
56 - GetConfig.log("[GETX] OPEN DIALOG ${route?.settings?.name}");  
57 - } else {  
58 - GetConfig.log("[GETX] GOING TO ROUTE ${route?.settings?.name}"); 68 + bool isGetPageRoute = route is GetPageRoute;
  69 + bool isSnackbar = route is SnackRoute;
  70 + bool isDialog = route is GetDialogRoute;
  71 + bool isBottomSheet = route is GetModalBottomSheetRoute;
  72 + String routeName = name(route);
  73 +
  74 + if (isSnackbar) {
  75 + GetConfig.log("[GETX] OPEN SNACKBAR $routeName");
  76 + } else if (isBottomSheet) {
  77 + GetConfig.log("[GETX] OPEN $routeName");
  78 + } else if (isDialog) {
  79 + GetConfig.log("[GETX] OPEN $routeName");
  80 + } else if (isGetPageRoute) {
  81 + GetConfig.log("[GETX] GOING TO ROUTE $routeName");
59 } 82 }
  83 + GetConfig.currentRoute = routeName;
60 84
61 _routeSend.update((value) { 85 _routeSend.update((value) {
62 - if (route is PageRoute) value.current = '${route?.settings?.name}'; 86 + if (route is PageRoute) value.current = routeName;
63 value.args = route?.settings?.arguments; 87 value.args = route?.settings?.arguments;
64 value.route = route; 88 value.route = route;
65 value.isBack = false; 89 value.isBack = false;
66 value.removed = ''; 90 value.removed = '';
67 value.previous = '${previousRoute?.settings?.name}'; 91 value.previous = '${previousRoute?.settings?.name}';
68 - value.isSnackbar = '${route?.settings?.name}' == 'snackbar';  
69 - value.isBottomSheet = '${route?.settings?.name}' == 'bottomsheet';  
70 - value.isDialog = '${route?.settings?.name}' == 'dialog'; 92 + value.isSnackbar = isSnackbar;
  93 + value.isBottomSheet = isBottomSheet;
  94 + value.isDialog = isDialog;
71 }); 95 });
72 if (routing != null) routing(_routeSend); 96 if (routing != null) routing(_routeSend);
73 } 97 }
@@ -76,15 +100,22 @@ class GetObserver extends NavigatorObserver { @@ -76,15 +100,22 @@ class GetObserver extends NavigatorObserver {
76 void didPop(Route route, Route previousRoute) { 100 void didPop(Route route, Route previousRoute) {
77 super.didPop(route, previousRoute); 101 super.didPop(route, previousRoute);
78 102
79 - if ('${route?.settings?.name}' == 'snackbar') {  
80 - GetConfig.log("[GETX] CLOSE SNACKBAR ${route?.settings?.name}");  
81 - } else if ('${route?.settings?.name}' == 'bottomsheet') {  
82 - GetConfig.log("[GETX] CLOSE BOTTOMSHEET ${route?.settings?.name}");  
83 - } else if ('${route?.settings?.name}' == 'dialog') {  
84 - GetConfig.log("[GETX] CLOSE DIALOG ${route?.settings?.name}");  
85 - } else {  
86 - GetConfig.log("[GETX] BACK ROUTE ${route?.settings?.name}"); 103 + bool isGetPageRoute = route is GetPageRoute;
  104 + bool isSnackbar = route is SnackRoute;
  105 + bool isDialog = route is GetDialogRoute;
  106 + bool isBottomSheet = route is GetModalBottomSheetRoute;
  107 + String routeName = name(route);
  108 +
  109 + if (isSnackbar) {
  110 + GetConfig.log("[GETX] CLOSE SNACKBAR $routeName");
  111 + } else if (isBottomSheet) {
  112 + GetConfig.log("[GETX] CLOSE $routeName");
  113 + } else if (isDialog) {
  114 + GetConfig.log("[GETX] CLOSE $routeName");
  115 + } else if (isGetPageRoute) {
  116 + GetConfig.log("[GETX] CLOSE TO ROUTE $routeName");
87 } 117 }
  118 + GetConfig.currentRoute = routeName;
88 119
89 _routeSend.update((value) { 120 _routeSend.update((value) {
90 if (previousRoute is PageRoute) 121 if (previousRoute is PageRoute)
@@ -104,9 +135,12 @@ class GetObserver extends NavigatorObserver { @@ -104,9 +135,12 @@ class GetObserver extends NavigatorObserver {
104 @override 135 @override
105 void didReplace({Route newRoute, Route oldRoute}) { 136 void didReplace({Route newRoute, Route oldRoute}) {
106 super.didReplace(newRoute: newRoute, oldRoute: oldRoute); 137 super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
  138 +
107 GetConfig.log("[GETX] REPLACE ROUTE ${oldRoute?.settings?.name}"); 139 GetConfig.log("[GETX] REPLACE ROUTE ${oldRoute?.settings?.name}");
108 GetConfig.log("[GETX] NEW ROUTE ${newRoute?.settings?.name}"); 140 GetConfig.log("[GETX] NEW ROUTE ${newRoute?.settings?.name}");
109 141
  142 + GetConfig.currentRoute = name(newRoute);
  143 +
110 _routeSend.update((value) { 144 _routeSend.update((value) {
111 if (newRoute is PageRoute) value.current = '${newRoute?.settings?.name}'; 145 if (newRoute is PageRoute) value.current = '${newRoute?.settings?.name}';
112 value.args = newRoute?.settings?.arguments; 146 value.args = newRoute?.settings?.arguments;
1 name: get 1 name: get
2 description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. 2 description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX.
3 -version: 3.4.6 3 +version: 3.5.0
4 homepage: https://github.com/jonataslaw/get 4 homepage: https://github.com/jonataslaw/get
5 5
6 environment: 6 environment:
7 - sdk: ">=2.6.0 <3.0.0" 7 + sdk: ">=2.8.0 <3.0.0"
8 8
9 dependencies: 9 dependencies:
10 flutter: 10 flutter: