Jonatas Borges

improve rx

No preview for this file type
  1 +## [4.1.1]
  2 +- default type to non nullables types
  3 +
  4 +## [4.1.0]
  5 +- Added Rxn to non nullables reactives types
  6 +
1 ## [4.0.3] 7 ## [4.0.3]
2 - Added new linter rules to improve score 8 - Added new linter rules to improve score
3 9
@@ -5,7 +5,7 @@ import 'en_us.dart'; @@ -5,7 +5,7 @@ import 'en_us.dart';
5 import 'pt_br.dart'; 5 import 'pt_br.dart';
6 6
7 class TranslationService extends Translations { 7 class TranslationService extends Translations {
8 - static Locale get locale => Get.deviceLocale!; 8 + static Locale get locale => Get.deviceLocale;
9 static final fallbackLocale = Locale('en', 'US'); 9 static final fallbackLocale = Locale('en', 'US');
10 @override 10 @override
11 Map<String, Map<String, String>> get keys => { 11 Map<String, Map<String, String>> get keys => {
@@ -13,7 +13,6 @@ class MyApp extends StatelessWidget { @@ -13,7 +13,6 @@ class MyApp extends StatelessWidget {
13 13
14 @override 14 @override
15 Widget build(BuildContext context) { 15 Widget build(BuildContext context) {
16 - Get.theme!.accentColor;  
17 return GetMaterialApp( 16 return GetMaterialApp(
18 debugShowCheckedModeBanner: false, 17 debugShowCheckedModeBanner: false,
19 enableLog: true, 18 enableLog: true,
@@ -99,7 +99,7 @@ extension ExtensionSnackbar on GetInterface { @@ -99,7 +99,7 @@ extension ExtensionSnackbar on GetInterface {
99 } 99 }
100 100
101 Future<T?>? showSnackbar<T>(GetBar snackbar) { 101 Future<T?>? showSnackbar<T>(GetBar snackbar) {
102 - return key?.currentState?.push(SnackRoute<T>(snack: snackbar)); 102 + return key.currentState?.push(SnackRoute<T>(snack: snackbar));
103 } 103 }
104 104
105 void snackbar<T>( 105 void snackbar<T>(
@@ -322,7 +322,7 @@ extension ExtensionDialog on GetInterface { @@ -322,7 +322,7 @@ extension ExtensionDialog on GetInterface {
322 padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8), 322 padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8),
323 shape: RoundedRectangleBorder( 323 shape: RoundedRectangleBorder(
324 side: BorderSide( 324 side: BorderSide(
325 - color: buttonColor ?? theme!.accentColor, 325 + color: buttonColor ?? theme.accentColor,
326 width: 2, 326 width: 2,
327 style: BorderStyle.solid), 327 style: BorderStyle.solid),
328 borderRadius: BorderRadius.circular(100)), 328 borderRadius: BorderRadius.circular(100)),
@@ -333,7 +333,7 @@ extension ExtensionDialog on GetInterface { @@ -333,7 +333,7 @@ extension ExtensionDialog on GetInterface {
333 }, 333 },
334 child: Text( 334 child: Text(
335 textCancel ?? "Cancel", 335 textCancel ?? "Cancel",
336 - style: TextStyle(color: cancelTextColor ?? theme!.accentColor), 336 + style: TextStyle(color: cancelTextColor ?? theme.accentColor),
337 ), 337 ),
338 )); 338 ));
339 } 339 }
@@ -346,14 +346,14 @@ extension ExtensionDialog on GetInterface { @@ -346,14 +346,14 @@ extension ExtensionDialog on GetInterface {
346 style: TextButton.styleFrom( 346 style: TextButton.styleFrom(
347 tapTargetSize: MaterialTapTargetSize.shrinkWrap, 347 tapTargetSize: MaterialTapTargetSize.shrinkWrap,
348 //color: buttonColor ?? theme.accentColor, 348 //color: buttonColor ?? theme.accentColor,
349 - backgroundColor: buttonColor ?? theme!.accentColor, 349 + backgroundColor: buttonColor ?? theme.accentColor,
350 shape: RoundedRectangleBorder( 350 shape: RoundedRectangleBorder(
351 borderRadius: BorderRadius.circular(100)), 351 borderRadius: BorderRadius.circular(100)),
352 ), 352 ),
353 child: Text( 353 child: Text(
354 textConfirm ?? "Ok", 354 textConfirm ?? "Ok",
355 style: 355 style:
356 - TextStyle(color: confirmTextColor ?? theme!.backgroundColor), 356 + TextStyle(color: confirmTextColor ?? theme.backgroundColor),
357 ), 357 ),
358 onPressed: () { 358 onPressed: () {
359 onConfirm?.call(); 359 onConfirm?.call();
@@ -364,7 +364,7 @@ extension ExtensionDialog on GetInterface { @@ -364,7 +364,7 @@ extension ExtensionDialog on GetInterface {
364 Widget baseAlertDialog = AlertDialog( 364 Widget baseAlertDialog = AlertDialog(
365 titlePadding: EdgeInsets.all(8), 365 titlePadding: EdgeInsets.all(8),
366 contentPadding: EdgeInsets.all(8), 366 contentPadding: EdgeInsets.all(8),
367 - backgroundColor: backgroundColor ?? theme!.dialogBackgroundColor, 367 + backgroundColor: backgroundColor ?? theme.dialogBackgroundColor,
368 shape: RoundedRectangleBorder( 368 shape: RoundedRectangleBorder(
369 borderRadius: BorderRadius.all(Radius.circular(radius))), 369 borderRadius: BorderRadius.all(Radius.circular(radius))),
370 title: Text(title, textAlign: TextAlign.center, style: titleStyle), 370 title: Text(title, textAlign: TextAlign.center, style: titleStyle),
@@ -432,9 +432,9 @@ extension ExtensionBottomSheet on GetInterface { @@ -432,9 +432,9 @@ extension ExtensionBottomSheet on GetInterface {
432 builder: (_) => bottomsheet, 432 builder: (_) => bottomsheet,
433 isPersistent: persistent, 433 isPersistent: persistent,
434 // theme: Theme.of(key.currentContext, shadowThemeOnly: true), 434 // theme: Theme.of(key.currentContext, shadowThemeOnly: true),
435 - theme: Theme.of(key!.currentContext!), 435 + theme: Theme.of(key.currentContext!),
436 isScrollControlled: isScrollControlled, 436 isScrollControlled: isScrollControlled,
437 - barrierLabel: MaterialLocalizations.of(key!.currentContext!) 437 + barrierLabel: MaterialLocalizations.of(key.currentContext!)
438 .modalBarrierDismissLabel, 438 .modalBarrierDismissLabel,
439 backgroundColor: backgroundColor ?? Colors.transparent, 439 backgroundColor: backgroundColor ?? Colors.transparent,
440 elevation: elevation, 440 elevation: elevation,
@@ -491,7 +491,7 @@ extension GetNavigation on GetInterface { @@ -491,7 +491,7 @@ extension GetNavigation on GetInterface {
491 if (preventDuplicates && routeName == currentRoute) { 491 if (preventDuplicates && routeName == currentRoute) {
492 return null; 492 return null;
493 } 493 }
494 - return global(id)?.currentState?.push<T>( 494 + return global(id).currentState?.push<T>(
495 GetPageRoute<T>( 495 GetPageRoute<T>(
496 opaque: opaque ?? true, 496 opaque: opaque ?? true,
497 page: _resolve(page, 'to'), 497 page: _resolve(page, 'to'),
@@ -557,7 +557,7 @@ you can only use widgets and widget functions here'''; @@ -557,7 +557,7 @@ you can only use widgets and widget functions here''';
557 page = uri.toString(); 557 page = uri.toString();
558 } 558 }
559 559
560 - return global(id)?.currentState?.pushNamed<T>( 560 + return global(id).currentState?.pushNamed<T>(
561 page, 561 page,
562 arguments: arguments, 562 arguments: arguments,
563 ); 563 );
@@ -594,7 +594,7 @@ you can only use widgets and widget functions here'''; @@ -594,7 +594,7 @@ you can only use widgets and widget functions here''';
594 final uri = Uri(path: page, queryParameters: parameters); 594 final uri = Uri(path: page, queryParameters: parameters);
595 page = uri.toString(); 595 page = uri.toString();
596 } 596 }
597 - return global(id)?.currentState?.pushReplacementNamed( 597 + return global(id).currentState?.pushReplacementNamed(
598 page, 598 page,
599 arguments: arguments, 599 arguments: arguments,
600 ); 600 );
@@ -616,7 +616,7 @@ you can only use widgets and widget functions here'''; @@ -616,7 +616,7 @@ you can only use widgets and widget functions here''';
616 void until(RoutePredicate predicate, {int? id}) { 616 void until(RoutePredicate predicate, {int? id}) {
617 // if (key.currentState.mounted) // add this if appear problems on future with route navigate 617 // if (key.currentState.mounted) // add this if appear problems on future with route navigate
618 // when widget don't mounted 618 // when widget don't mounted
619 - return global(id)?.currentState?.popUntil(predicate); 619 + return global(id).currentState?.popUntil(predicate);
620 } 620 }
621 621
622 /// **Navigation.pushAndRemoveUntil()** shortcut.<br><br> 622 /// **Navigation.pushAndRemoveUntil()** shortcut.<br><br>
@@ -640,7 +640,7 @@ you can only use widgets and widget functions here'''; @@ -640,7 +640,7 @@ you can only use widgets and widget functions here''';
640 Future<T?>? offUntil<T>(Route<T> page, RoutePredicate predicate, {int? id}) { 640 Future<T?>? offUntil<T>(Route<T> page, RoutePredicate predicate, {int? id}) {
641 // if (key.currentState.mounted) // add this if appear problems on future with route navigate 641 // if (key.currentState.mounted) // add this if appear problems on future with route navigate
642 // when widget don't mounted 642 // when widget don't mounted
643 - return global(id)?.currentState?.pushAndRemoveUntil<T>(page, predicate); 643 + return global(id).currentState?.pushAndRemoveUntil<T>(page, predicate);
644 } 644 }
645 645
646 /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> 646 /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br>
@@ -673,7 +673,7 @@ you can only use widgets and widget functions here'''; @@ -673,7 +673,7 @@ you can only use widgets and widget functions here''';
673 page = uri.toString(); 673 page = uri.toString();
674 } 674 }
675 675
676 - return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( 676 + return global(id).currentState?.pushNamedAndRemoveUntil<T>(
677 page, 677 page,
678 predicate, 678 predicate,
679 arguments: arguments, 679 arguments: arguments,
@@ -702,7 +702,7 @@ you can only use widgets and widget functions here'''; @@ -702,7 +702,7 @@ you can only use widgets and widget functions here''';
702 final uri = Uri(path: page, queryParameters: parameters); 702 final uri = Uri(path: page, queryParameters: parameters);
703 page = uri.toString(); 703 page = uri.toString();
704 } 704 }
705 - return global(id)?.currentState?.popAndPushNamed( 705 + return global(id).currentState?.popAndPushNamed(
706 page, 706 page,
707 arguments: arguments, 707 arguments: arguments,
708 result: result, 708 result: result,
@@ -716,7 +716,7 @@ you can only use widgets and widget functions here'''; @@ -716,7 +716,7 @@ you can only use widgets and widget functions here''';
716 /// [id] is for when you are using nested navigation, 716 /// [id] is for when you are using nested navigation,
717 /// as explained in documentation 717 /// as explained in documentation
718 void removeRoute(Route<dynamic> route, {int? id}) { 718 void removeRoute(Route<dynamic> route, {int? id}) {
719 - return global(id)?.currentState?.removeRoute(route); 719 + return global(id).currentState?.removeRoute(route);
720 } 720 }
721 721
722 /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br> 722 /// **Navigation.pushNamedAndRemoveUntil()** shortcut.<br><br>
@@ -751,7 +751,7 @@ you can only use widgets and widget functions here'''; @@ -751,7 +751,7 @@ you can only use widgets and widget functions here''';
751 newRouteName = uri.toString(); 751 newRouteName = uri.toString();
752 } 752 }
753 753
754 - return global(id)?.currentState?.pushNamedAndRemoveUntil<T>( 754 + return global(id).currentState?.pushNamedAndRemoveUntil<T>(
755 newRouteName, 755 newRouteName,
756 predicate ?? (_) => false, 756 predicate ?? (_) => false,
757 arguments: arguments, 757 arguments: arguments,
@@ -790,11 +790,11 @@ you can only use widgets and widget functions here'''; @@ -790,11 +790,11 @@ you can only use widgets and widget functions here''';
790 }); 790 });
791 } 791 }
792 if (canPop) { 792 if (canPop) {
793 - if (global(id)?.currentState?.canPop() == true) {  
794 - global(id)?.currentState?.pop<T>(result); 793 + if (global(id).currentState?.canPop() == true) {
  794 + global(id).currentState?.pop<T>(result);
795 } 795 }
796 } else { 796 } else {
797 - global(id)?.currentState?.pop<T>(result); 797 + global(id).currentState?.pop<T>(result);
798 } 798 }
799 } 799 }
800 800
@@ -809,7 +809,7 @@ you can only use widgets and widget functions here'''; @@ -809,7 +809,7 @@ you can only use widgets and widget functions here''';
809 times = 1; 809 times = 1;
810 } 810 }
811 var count = 0; 811 var count = 0;
812 - var back = global(id)?.currentState?.popUntil((route) => count++ == times); 812 + var back = global(id).currentState?.popUntil((route) => count++ == times);
813 813
814 return back; 814 return back;
815 } 815 }
@@ -856,7 +856,7 @@ you can only use widgets and widget functions here'''; @@ -856,7 +856,7 @@ you can only use widgets and widget functions here''';
856 if (preventDuplicates && routeName == currentRoute) { 856 if (preventDuplicates && routeName == currentRoute) {
857 return null; 857 return null;
858 } 858 }
859 - return global(id)?.currentState?.pushReplacement(GetPageRoute( 859 + return global(id).currentState?.pushReplacement(GetPageRoute(
860 opaque: opaque, 860 opaque: opaque,
861 page: _resolve(page, 'off'), 861 page: _resolve(page, 'off'),
862 binding: binding, 862 binding: binding,
@@ -915,7 +915,7 @@ you can only use widgets and widget functions here'''; @@ -915,7 +915,7 @@ you can only use widgets and widget functions here''';
915 }) { 915 }) {
916 var routeName = "/${page.runtimeType.toString()}"; 916 var routeName = "/${page.runtimeType.toString()}";
917 917
918 - return global(id)?.currentState?.pushAndRemoveUntil<T>( 918 + return global(id).currentState?.pushAndRemoveUntil<T>(
919 GetPageRoute<T>( 919 GetPageRoute<T>(
920 opaque: opaque, 920 opaque: opaque,
921 popGesture: popGesture ?? defaultPopGesture, 921 popGesture: popGesture ?? defaultPopGesture,
@@ -1006,7 +1006,7 @@ you can only use widgets and widget functions here'''; @@ -1006,7 +1006,7 @@ you can only use widgets and widget functions here''';
1006 getxController.setThemeMode(themeMode); 1006 getxController.setThemeMode(themeMode);
1007 } 1007 }
1008 1008
1009 - GlobalKey<NavigatorState>? addKey(GlobalKey<NavigatorState>? newKey) { 1009 + GlobalKey<NavigatorState>? addKey(GlobalKey<NavigatorState> newKey) {
1010 getxController.key = newKey; 1010 getxController.key = newKey;
1011 return key; 1011 return key;
1012 } 1012 }
@@ -1016,18 +1016,18 @@ you can only use widgets and widget functions here'''; @@ -1016,18 +1016,18 @@ you can only use widgets and widget functions here''';
1016 return keys[key]; 1016 return keys[key];
1017 } 1017 }
1018 1018
1019 - GlobalKey<NavigatorState>? global(int? k) {  
1020 - GlobalKey<NavigatorState>? _key; 1019 + GlobalKey<NavigatorState> global(int? k) {
  1020 + GlobalKey<NavigatorState> _key;
1021 if (k == null) { 1021 if (k == null) {
1022 _key = key; 1022 _key = key;
1023 } else { 1023 } else {
1024 if (!keys.containsKey(k)) { 1024 if (!keys.containsKey(k)) {
1025 throw 'Route id ($k) not found'; 1025 throw 'Route id ($k) not found';
1026 } 1026 }
1027 - _key = keys[k]; 1027 + _key = keys[k]!;
1028 } 1028 }
1029 1029
1030 - if (_key!.currentContext == null && !testMode) { 1030 + if (_key.currentContext == null && !testMode) {
1031 throw """You are trying to use contextless navigation without 1031 throw """You are trying to use contextless navigation without
1032 a GetMaterialApp or Get.key. 1032 a GetMaterialApp or Get.key.
1033 If you are testing your app, you can use: 1033 If you are testing your app, you can use:
@@ -1040,12 +1040,6 @@ you can only use widgets and widget functions here'''; @@ -1040,12 +1040,6 @@ you can only use widgets and widget functions here''';
1040 return _key; 1040 return _key;
1041 } 1041 }
1042 1042
1043 - @Deprecated('''  
1044 -Since version 2.8 it is possible to access the properties  
1045 -[Get.arguments] and [Get.currentRoute] directly.  
1046 -[routeSettings] is useless and should not be used.''')  
1047 - RouteSettings? get routeSettings => null;  
1048 -  
1049 /// give current arguments 1043 /// give current arguments
1050 dynamic get arguments => routing.args; 1044 dynamic get arguments => routing.args;
1051 1045
@@ -1074,20 +1068,20 @@ Since version 2.8 it is possible to access the properties @@ -1074,20 +1068,20 @@ Since version 2.8 it is possible to access the properties
1074 bool get isOpaqueRouteDefault => defaultOpaqueRoute; 1068 bool get isOpaqueRouteDefault => defaultOpaqueRoute;
1075 1069
1076 /// give access to currentContext 1070 /// give access to currentContext
1077 - BuildContext? get context => key?.currentContext; 1071 + BuildContext? get context => key.currentContext;
1078 1072
1079 /// give access to current Overlay Context 1073 /// give access to current Overlay Context
1080 BuildContext? get overlayContext { 1074 BuildContext? get overlayContext {
1081 BuildContext? overlay; 1075 BuildContext? overlay;
1082 - key?.currentState?.overlay?.context.visitChildElements((element) { 1076 + key.currentState?.overlay?.context.visitChildElements((element) {
1083 overlay = element; 1077 overlay = element;
1084 }); 1078 });
1085 return overlay; 1079 return overlay;
1086 } 1080 }
1087 1081
1088 /// give access to Theme.of(context) 1082 /// give access to Theme.of(context)
1089 - ThemeData? get theme {  
1090 - ThemeData? _theme; 1083 + ThemeData get theme {
  1084 + var _theme = ThemeData.fallback();
1091 if (context != null) { 1085 if (context != null) {
1092 _theme = Theme.of(context!); 1086 _theme = Theme.of(context!);
1093 } 1087 }
@@ -1105,7 +1099,7 @@ Since version 2.8 it is possible to access the properties @@ -1105,7 +1099,7 @@ Since version 2.8 it is possible to access the properties
1105 /// The window to which this binding is bound. 1099 /// The window to which this binding is bound.
1106 ui.SingletonFlutterWindow get window => ui.window; 1100 ui.SingletonFlutterWindow get window => ui.window;
1107 1101
1108 - Locale? get deviceLocale => ui.window.locale; 1102 + Locale get deviceLocale => ui.window.locale;
1109 1103
1110 ///The number of device pixels for each logical pixel. 1104 ///The number of device pixels for each logical pixel.
1111 double get pixelRatio => ui.window.devicePixelRatio; 1105 double get pixelRatio => ui.window.devicePixelRatio;
@@ -1130,20 +1124,20 @@ Since version 2.8 it is possible to access the properties @@ -1130,20 +1124,20 @@ Since version 2.8 it is possible to access the properties
1130 double get textScaleFactor => ui.window.textScaleFactor; 1124 double get textScaleFactor => ui.window.textScaleFactor;
1131 1125
1132 /// give access to TextTheme.of(context) 1126 /// give access to TextTheme.of(context)
1133 - TextTheme? get textTheme => theme?.textTheme; 1127 + TextTheme get textTheme => theme.textTheme;
1134 1128
1135 /// give access to Mediaquery.of(context) 1129 /// give access to Mediaquery.of(context)
1136 MediaQueryData get mediaQuery => MediaQuery.of(context!); 1130 MediaQueryData get mediaQuery => MediaQuery.of(context!);
1137 1131
1138 /// Check if dark mode theme is enable 1132 /// Check if dark mode theme is enable
1139 - bool get isDarkMode => (theme!.brightness == Brightness.dark); 1133 + bool get isDarkMode => (theme.brightness == Brightness.dark);
1140 1134
1141 /// Check if dark mode theme is enable on platform on android Q+ 1135 /// Check if dark mode theme is enable on platform on android Q+
1142 bool get isPlatformDarkMode => 1136 bool get isPlatformDarkMode =>
1143 (ui.window.platformBrightness == Brightness.dark); 1137 (ui.window.platformBrightness == Brightness.dark);
1144 1138
1145 /// give access to Theme.of(context).iconTheme.color 1139 /// give access to Theme.of(context).iconTheme.color
1146 - Color? get iconColor => theme?.iconTheme.color; 1140 + Color? get iconColor => theme.iconTheme.color;
1147 1141
1148 /// give access to FocusScope.of(context) 1142 /// give access to FocusScope.of(context)
1149 FocusNode? get focusScope => FocusManager.instance.primaryFocus; 1143 FocusNode? get focusScope => FocusManager.instance.primaryFocus;
@@ -1154,7 +1148,7 @@ Since version 2.8 it is possible to access the properties @@ -1154,7 +1148,7 @@ Since version 2.8 it is possible to access the properties
1154 // /// give access to Immutable MediaQuery.of(context).size.width 1148 // /// give access to Immutable MediaQuery.of(context).size.width
1155 // double get width => MediaQuery.of(context).size.width; 1149 // double get width => MediaQuery.of(context).size.width;
1156 1150
1157 - GlobalKey<NavigatorState>? get key => getxController.key; 1151 + GlobalKey<NavigatorState> get key => getxController.key;
1158 1152
1159 Map<dynamic, GlobalKey<NavigatorState>> get keys => getxController.keys; 1153 Map<dynamic, GlobalKey<NavigatorState>> get keys => getxController.keys;
1160 1154
@@ -1201,4 +1195,4 @@ Since version 2.8 it is possible to access the properties @@ -1201,4 +1195,4 @@ Since version 2.8 it is possible to access the properties
1201 /// It replaces the Flutter Navigator, but needs no context. 1195 /// It replaces the Flutter Navigator, but needs no context.
1202 /// You can to use navigator.push(YourRoute()) rather 1196 /// You can to use navigator.push(YourRoute()) rather
1203 /// Navigator.push(context, YourRoute()); 1197 /// Navigator.push(context, YourRoute());
1204 -NavigatorState? get navigator => GetNavigation(Get).key!.currentState; 1198 +NavigatorState? get navigator => GetNavigation(Get).key.currentState;
@@ -253,7 +253,7 @@ class GetCupertinoApp extends StatelessWidget { @@ -253,7 +253,7 @@ class GetCupertinoApp extends StatelessWidget {
253 key: _.unikey, 253 key: _.unikey,
254 theme: theme, 254 theme: theme,
255 navigatorKey: 255 navigatorKey:
256 - (navigatorKey == null ? Get.key : Get.addKey(navigatorKey)), 256 + (navigatorKey == null ? Get.key : Get.addKey(navigatorKey!)),
257 home: home, 257 home: home,
258 routes: routes ?? const <String, WidgetBuilder>{}, 258 routes: routes ?? const <String, WidgetBuilder>{},
259 initialRoute: initialRoute, 259 initialRoute: initialRoute,
@@ -263,7 +263,7 @@ class GetMaterialApp extends StatelessWidget { @@ -263,7 +263,7 @@ class GetMaterialApp extends StatelessWidget {
263 : MaterialApp( 263 : MaterialApp(
264 key: _.unikey, 264 key: _.unikey,
265 navigatorKey: 265 navigatorKey:
266 - (navigatorKey == null ? Get.key : Get.addKey(navigatorKey)), 266 + (navigatorKey == null ? Get.key : Get.addKey(navigatorKey!)),
267 home: home, 267 home: home,
268 routes: routes ?? const <String, WidgetBuilder>{}, 268 routes: routes ?? const <String, WidgetBuilder>{},
269 initialRoute: initialRoute, 269 initialRoute: initialRoute,
@@ -31,9 +31,9 @@ class GetMaterialController extends GetxController { @@ -31,9 +31,9 @@ class GetMaterialController extends GetxController {
31 31
32 CustomTransition? customTransition; 32 CustomTransition? customTransition;
33 33
34 - GlobalKey<NavigatorState>? key = GlobalKey<NavigatorState>(); 34 + GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
35 35
36 - Map<int, GlobalKey<NavigatorState>> keys = {}; 36 + Map<dynamic, GlobalKey<NavigatorState>> keys = {};
37 37
38 void setTheme(ThemeData value) { 38 void setTheme(ThemeData value) {
39 theme = value; 39 theme = value;
@@ -247,7 +247,7 @@ class RxBool extends Rx<bool> { @@ -247,7 +247,7 @@ class RxBool extends Rx<bool> {
247 } 247 }
248 248
249 class RxnBool extends Rx<bool?> { 249 class RxnBool extends Rx<bool?> {
250 - RxnBool(bool initial) : super(initial); 250 + RxnBool([bool? initial]) : super(initial);
251 @override 251 @override
252 String toString() { 252 String toString() {
253 return "$value"; 253 return "$value";
@@ -327,6 +327,19 @@ class Rx<T> extends _RxImpl<T> { @@ -327,6 +327,19 @@ class Rx<T> extends _RxImpl<T> {
327 } 327 }
328 } 328 }
329 329
  330 +class Rxn<T> extends Rx<T?> {
  331 + Rxn([T? initial]) : super(initial);
  332 +
  333 + @override
  334 + dynamic toJson() {
  335 + try {
  336 + return (value as dynamic)?.toJson();
  337 + } on Exception catch (_) {
  338 + throw '$T has not method [toJson]';
  339 + }
  340 + }
  341 +}
  342 +
330 extension StringExtension on String { 343 extension StringExtension on String {
331 /// Returns a `RxString` with [this] `String` as initial value. 344 /// Returns a `RxString` with [this] `String` as initial value.
332 RxString get obs => RxString(this); 345 RxString get obs => RxString(this);
@@ -578,7 +578,7 @@ class RxNum extends Rx<num> { @@ -578,7 +578,7 @@ class RxNum extends Rx<num> {
578 } 578 }
579 579
580 class RxnNum extends Rx<num?> { 580 class RxnNum extends Rx<num?> {
581 - RxnNum(num initial) : super(initial); 581 + RxnNum([num? initial]) : super(initial);
582 582
583 num? operator +(num other) { 583 num? operator +(num other) {
584 if (value != null) { 584 if (value != null) {
@@ -270,7 +270,7 @@ class RxString extends Rx<String> implements Comparable<String>, Pattern { @@ -270,7 +270,7 @@ class RxString extends Rx<String> implements Comparable<String>, Pattern {
270 270
271 /// Rx class for `String` Type. 271 /// Rx class for `String` Type.
272 class RxnString extends Rx<String?> implements Comparable<String>, Pattern { 272 class RxnString extends Rx<String?> implements Comparable<String>, Pattern {
273 - RxnString(String? initial) : super(initial); 273 + RxnString([String? initial]) : super(initial);
274 274
275 @override 275 @override
276 Iterable<Match> allMatches(String string, [int start = 0]) { 276 Iterable<Match> allMatches(String string, [int start = 0]) {
1 name: get 1 name: get
2 description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX. 2 description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
3 -version: 4.0.3 3 +version: 4.1.1
4 homepage: https://github.com/jonataslaw/getx 4 homepage: https://github.com/jonataslaw/getx
5 5
6 environment: 6 environment: