LCOV - code coverage report
Current view: top level - src - get_main.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 112 182 61.5 %
Date: 2020-06-12 23:08:29 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : import 'package:flutter/scheduler.dart';
       3             : import 'package:get_core/get.dart';
       4             : import 'package:get_core/src/get_interface.dart';
       5             : import 'bottomsheet/bottomsheet.dart';
       6             : import 'platform/platform.dart';
       7             : import 'root/root_controller.dart';
       8             : import 'routes/bindings_interface.dart';
       9             : import 'routes/default_route.dart';
      10             : import 'routes/observers/route_observer.dart';
      11             : import 'routes/transitions_type.dart';
      12             : import 'snackbar/snack.dart';
      13             : 
      14             : // ignore: non_constant_identifier_names
      15          24 : final Get = GetImpl();
      16             : 
      17             : ///Use to instead of Navigator.push, off instead of Navigator.pushReplacement,
      18             : ///offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named"
      19             : ///after them. Example: toNamed, offNamed, and AllNamed.
      20             : ///To return to the previous screen, use back().
      21             : ///No need to pass any context to Get, just put the name of the route inside
      22             : ///the parentheses and the magic will occur.
      23             : class GetImpl implements GetInterface {
      24             :   bool defaultPopGesture = GetPlatform.isIOS;
      25             :   bool defaultOpaqueRoute = true;
      26             :   Transition defaultTransition =
      27             :       (GetPlatform.isIOS ? Transition.cupertino : Transition.fade);
      28             :   Duration defaultDurationTransition = Duration(milliseconds: 400);
      29             :   bool defaultGlobalState = true;
      30             :   RouteSettings settings;
      31             : 
      32             :   ///Use to instead of Navigator.push, off instead of Navigator.pushReplacement,
      33             :   ///offAll instead of Navigator.pushAndRemoveUntil. For named routes just add "named"
      34             :   ///after them. Example: toNamed, offNamed, and AllNamed.
      35             :   ///To return to the previous screen, use back().
      36             :   ///No need to pass any context to Get, just put the name of the route inside
      37             :   ///the parentheses and the magic will occur.
      38             : 
      39             :   /// It replaces Navigator.push, but needs no context, and it doesn't have the Navigator.push
      40             :   /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
      41             :   /// of rebuilding every app after a route, use opaque = true as the parameter.
      42           1 :   Future<T> to<T>(Widget page,
      43             :       {bool opaque,
      44             :       Transition transition,
      45             :       Duration duration,
      46             :       int id,
      47             :       bool fullscreenDialog = false,
      48             :       Object arguments,
      49             :       Bindings binding,
      50             :       bool popGesture}) {
      51           4 :     return global(id).currentState.push(GetRouteBase(
      52             :         opaque: opaque ?? true,
      53             :         page: page,
      54           1 :         settings: RouteSettings(
      55           3 :             name: '/' + page.toString().toLowerCase(), arguments: arguments),
      56           1 :         popGesture: popGesture ?? defaultPopGesture,
      57           1 :         transition: transition ?? defaultTransition,
      58             :         fullscreenDialog: fullscreenDialog,
      59             :         binding: binding,
      60           1 :         transitionDuration: duration ?? defaultDurationTransition));
      61             :   }
      62             : 
      63             :   /// It replaces Navigator.pushNamed, but needs no context, and it doesn't have the Navigator.pushNamed
      64             :   /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
      65             :   /// of rebuilding every app after a route, use opaque = true as the parameter.
      66           1 :   Future<T> toNamed<T>(String page, {Object arguments, int id}) {
      67             :     // if (key.currentState.mounted) // add this if appear problems on future with route navigate
      68             :     // when widget don't mounted
      69           3 :     return global(id).currentState.pushNamed(page, arguments: arguments);
      70             :   }
      71             : 
      72             :   /// It replaces Navigator.pushReplacementNamed, but needs no context.
      73           1 :   Future<T> offNamed<T>(String page, {Object arguments, int id}) {
      74             :     // if (key.currentState.mounted) // add this if appear problems on future with route navigate
      75             :     // when widget don't mounted
      76           1 :     return global(id)
      77           1 :         .currentState
      78           1 :         .pushReplacementNamed(page, arguments: arguments);
      79             :   }
      80             : 
      81             :   /// It replaces Navigator.popUntil, but needs no context.
      82           0 :   void until(RoutePredicate predicate, {int id}) {
      83             :     // if (key.currentState.mounted) // add this if appear problems on future with route navigate
      84             :     // when widget don't mounted
      85           0 :     return global(id).currentState.popUntil(predicate);
      86             :   }
      87             : 
      88             :   /// It replaces Navigator.pushAndRemoveUntil, but needs no context.
      89           1 :   Future<T> offUntil<T>(Route<T> page, RoutePredicate predicate, {int id}) {
      90             :     // if (key.currentState.mounted) // add this if appear problems on future with route navigate
      91             :     // when widget don't mounted
      92           3 :     return global(id).currentState.pushAndRemoveUntil(page, predicate);
      93             :   }
      94             : 
      95             :   /// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context.
      96           1 :   Future<T> offNamedUntil<T>(String page, RoutePredicate predicate,
      97             :       {int id, Object arguments}) {
      98           1 :     return global(id)
      99           1 :         .currentState
     100           1 :         .pushNamedAndRemoveUntil(page, predicate, arguments: arguments);
     101             :   }
     102             : 
     103             :   /// It replaces Navigator.popAndPushNamed, but needs no context.
     104           1 :   Future<T> offAndToNamed<T>(String page,
     105             :       {Object arguments, int id, dynamic result}) {
     106           1 :     return global(id)
     107           1 :         .currentState
     108           1 :         .popAndPushNamed(page, arguments: arguments, result: result);
     109             :   }
     110             : 
     111             :   /// It replaces Navigator.removeRoute, but needs no context.
     112           0 :   void removeRoute(Route<dynamic> route, {int id}) {
     113           0 :     return global(id).currentState.removeRoute(route);
     114             :   }
     115             : 
     116             :   /// It replaces Navigator.pushNamedAndRemoveUntil, but needs no context.
     117           1 :   Future<T> offAllNamed<T>(String newRouteName,
     118             :       {RoutePredicate predicate, Object arguments, int id}) {
     119           1 :     var route = (Route<dynamic> rota) => false;
     120             : 
     121           3 :     return global(id).currentState.pushNamedAndRemoveUntil(
     122             :         newRouteName, predicate ?? route,
     123             :         arguments: arguments);
     124             :   }
     125             : 
     126           0 :   bool get isOverlaysOpen =>
     127           0 :       (isSnackbarOpen || isDialogOpen || isBottomSheetOpen);
     128             : 
     129           0 :   bool get isOverlaysClosed =>
     130           0 :       (!isSnackbarOpen && !isDialogOpen && !isBottomSheetOpen);
     131             : 
     132             :   /// It replaces Navigator.pop, but needs no context.
     133           3 :   void back({dynamic result, bool closeOverlays = false, int id}) {
     134           0 :     if (closeOverlays && isOverlaysOpen) {
     135           0 :       navigator.popUntil((route) {
     136           0 :         return (isOverlaysClosed);
     137             :       });
     138             :     }
     139           9 :     global(id).currentState.pop(result);
     140             :   }
     141             : 
     142             :   /// It will close as many screens as you define. Times must be> 0;
     143           0 :   void close(int times, [int id]) {
     144           0 :     if ((times == null) || (times < 1)) {
     145             :       times = 1;
     146             :     }
     147             :     int count = 0;
     148           0 :     void back = global(id).currentState.popUntil((route) {
     149           0 :       return count++ == times;
     150             :     });
     151             :     return back;
     152             :   }
     153             : 
     154             :   /// It replaces Navigator.pushReplacement, but needs no context, and it doesn't have the Navigator.pushReplacement
     155             :   /// routes rebuild bug present in Flutter. If for some strange reason you want the default behavior
     156             :   /// of rebuilding every app after a route, use opaque = true as the parameter.
     157           1 :   Future<T> off<T>(Widget page,
     158             :       {bool opaque = false,
     159             :       Transition transition,
     160             :       bool popGesture,
     161             :       int id,
     162             :       Object arguments,
     163             :       Bindings binding,
     164             :       bool fullscreenDialog = false,
     165             :       Duration duration}) {
     166           4 :     return global(id).currentState.pushReplacement(GetRouteBase(
     167             :         opaque: opaque ?? true,
     168             :         page: page,
     169             :         binding: binding,
     170           1 :         settings: RouteSettings(
     171           3 :             name: '/' + page.toString().toLowerCase(), arguments: arguments),
     172             :         fullscreenDialog: fullscreenDialog,
     173           1 :         popGesture: popGesture ?? defaultPopGesture,
     174           1 :         transition: transition ?? defaultTransition,
     175           1 :         transitionDuration: duration ?? defaultDurationTransition));
     176             :   }
     177             : 
     178             :   /// It replaces Navigator.pushAndRemoveUntil, but needs no context
     179           1 :   Future<T> offAll<T>(Widget page,
     180             :       {RoutePredicate predicate,
     181             :       bool opaque = false,
     182             :       bool popGesture,
     183             :       int id,
     184             :       Object arguments,
     185             :       Bindings binding,
     186             :       bool fullscreenDialog = false,
     187             :       Transition transition}) {
     188           1 :     var route = (Route<dynamic> rota) => false;
     189             : 
     190           3 :     return global(id).currentState.pushAndRemoveUntil(
     191           1 :         GetRouteBase(
     192             :           opaque: opaque ?? true,
     193           1 :           popGesture: popGesture ?? defaultPopGesture,
     194             :           page: page,
     195             :           binding: binding,
     196           1 :           settings: RouteSettings(
     197           3 :               name: '/' + page.toString().toLowerCase(), arguments: arguments),
     198             :           fullscreenDialog: fullscreenDialog,
     199           1 :           transition: transition ?? defaultTransition,
     200             :         ),
     201             :         predicate ?? route);
     202             :   }
     203             : 
     204             :   /// Show a dialog
     205           1 :   Future<T> dialog<T>(
     206             :     Widget child, {
     207             :     bool barrierDismissible = true,
     208             :     bool useRootNavigator = true,
     209             :     //  RouteSettings routeSettings
     210             :   }) {
     211           1 :     return showDialog(
     212             :       barrierDismissible: barrierDismissible,
     213             :       useRootNavigator: useRootNavigator,
     214           1 :       routeSettings: RouteSettings(name: 'dialog'),
     215           1 :       context: overlayContext,
     216           1 :       builder: (_) {
     217             :         return child;
     218             :       },
     219             :     );
     220             :   }
     221             : 
     222             :   /// Api from showGeneralDialog with no context
     223           0 :   Future<T> generalDialog<T>({
     224             :     @required RoutePageBuilder pageBuilder,
     225             :     String barrierLabel = "Dismiss",
     226             :     bool barrierDismissible = true,
     227             :     Color barrierColor = const Color(0x80000000),
     228             :     Duration transitionDuration = const Duration(milliseconds: 200),
     229             :     RouteTransitionsBuilder transitionBuilder,
     230             :     bool useRootNavigator = true,
     231             :     RouteSettings routeSettings,
     232             :   }) {
     233           0 :     return showGeneralDialog(
     234             :       pageBuilder: pageBuilder,
     235             :       barrierDismissible: barrierDismissible,
     236             :       barrierLabel: barrierLabel,
     237             :       barrierColor: barrierColor,
     238             :       transitionDuration: transitionDuration,
     239             :       transitionBuilder: transitionBuilder,
     240             :       useRootNavigator: useRootNavigator,
     241           0 :       routeSettings: RouteSettings(name: 'dialog'),
     242           0 :       context: overlayContext,
     243             :     );
     244             :   }
     245             : 
     246           1 :   Future<T> defaultDialog<T>({
     247             :     String title = "Alert",
     248             :     Widget content,
     249             :     VoidCallback onConfirm,
     250             :     VoidCallback onCancel,
     251             :     VoidCallback onCustom,
     252             :     Color cancelTextColor,
     253             :     Color confirmTextColor,
     254             :     String textConfirm,
     255             :     String textCancel,
     256             :     String textCustom,
     257             :     Widget confirm,
     258             :     Widget cancel,
     259             :     Widget custom,
     260             :     Color backgroundColor,
     261             :     Color buttonColor,
     262             :     String middleText = "Dialog made in 3 lines of code",
     263             :     double radius = 20.0,
     264             :     List<Widget> actions,
     265             :   }) {
     266             :     bool leanCancel = onCancel != null || textCancel != null;
     267             :     bool leanConfirm = onConfirm != null || textConfirm != null;
     268           1 :     actions ??= [];
     269             : 
     270             :     if (cancel != null) {
     271           0 :       actions.add(cancel);
     272             :     } else {
     273             :       if (leanCancel) {
     274           0 :         actions.add(FlatButton(
     275             :           materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
     276           0 :           onPressed: () {
     277           0 :             onCancel?.call();
     278           0 :             back();
     279             :           },
     280           0 :           padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8),
     281           0 :           child: Text(
     282             :             textCancel ?? "Cancel",
     283           0 :             style: TextStyle(color: cancelTextColor ?? theme.accentColor),
     284             :           ),
     285           0 :           shape: RoundedRectangleBorder(
     286           0 :               side: BorderSide(
     287           0 :                   color: buttonColor ?? theme.accentColor,
     288             :                   width: 2,
     289             :                   style: BorderStyle.solid),
     290           0 :               borderRadius: BorderRadius.circular(100)),
     291             :         ));
     292             :       }
     293             :     }
     294             :     if (confirm != null) {
     295           0 :       actions.add(confirm);
     296             :     } else {
     297             :       if (leanConfirm) {
     298           2 :         actions.add(FlatButton(
     299             :             materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
     300           2 :             color: buttonColor ?? theme.accentColor,
     301           1 :             shape: RoundedRectangleBorder(
     302           1 :                 borderRadius: BorderRadius.circular(100)),
     303           1 :             child: Text(
     304             :               textConfirm ?? "Ok",
     305           3 :               style: TextStyle(color: confirmTextColor ?? theme.primaryColor),
     306             :             ),
     307           0 :             onPressed: () {
     308           0 :               onConfirm?.call();
     309             :             }));
     310             :       }
     311             :     }
     312           2 :     return dialog(AlertDialog(
     313           1 :       titlePadding: EdgeInsets.all(8),
     314           1 :       contentPadding: EdgeInsets.all(8),
     315           2 :       backgroundColor: backgroundColor ?? theme.dialogBackgroundColor,
     316           1 :       shape: RoundedRectangleBorder(
     317           2 :           borderRadius: BorderRadius.all(Radius.circular(radius))),
     318           1 :       title: Text(title, textAlign: TextAlign.center),
     319           1 :       content: Column(
     320             :         crossAxisAlignment: CrossAxisAlignment.center,
     321             :         mainAxisSize: MainAxisSize.min,
     322           1 :         children: [
     323           1 :           content ?? Text(middleText ?? "", textAlign: TextAlign.center),
     324           1 :           SizedBox(height: 16),
     325           1 :           ButtonTheme(
     326             :             minWidth: 78.0,
     327             :             height: 34.0,
     328           1 :             child: Wrap(
     329             :               alignment: WrapAlignment.center,
     330             :               spacing: 8,
     331             :               runSpacing: 8,
     332             :               children: actions,
     333             :             ),
     334             :           )
     335             :         ],
     336             :       ),
     337             :       // actions: actions, // ?? <Widget>[cancelButton, confirmButton],
     338             :       buttonPadding: EdgeInsets.zero,
     339             :     ));
     340             :   }
     341             : 
     342           1 :   Future<T> bottomSheet<T>(
     343             :     Widget bottomsheet, {
     344             :     Color backgroundColor,
     345             :     double elevation,
     346             :     ShapeBorder shape,
     347             :     Clip clipBehavior,
     348             :     Color barrierColor,
     349             :     bool ignoreSafeArea,
     350             :     bool isScrollControlled = false,
     351             :     bool useRootNavigator = false,
     352             :     bool isDismissible = true,
     353             :     bool enableDrag = true,
     354             :   }) {
     355           0 :     assert(bottomsheet != null);
     356           1 :     assert(isScrollControlled != null);
     357           0 :     assert(useRootNavigator != null);
     358           1 :     assert(isDismissible != null);
     359           1 :     assert(enableDrag != null);
     360             : 
     361           2 :     return Navigator.of(overlayContext, rootNavigator: useRootNavigator)
     362           2 :         .push(GetModalBottomSheetRoute<T>(
     363           1 :       builder: (_) => bottomsheet,
     364           3 :       theme: Theme.of(key.currentContext, shadowThemeOnly: true),
     365             :       isScrollControlled: isScrollControlled,
     366             :       barrierLabel:
     367           4 :           MaterialLocalizations.of(key.currentContext).modalBarrierDismissLabel,
     368             :       backgroundColor: backgroundColor ?? Colors.transparent,
     369             :       elevation: elevation,
     370             :       shape: shape,
     371             :       removeTop: ignoreSafeArea ?? true,
     372             :       clipBehavior: clipBehavior,
     373             :       isDismissible: isDismissible,
     374             :       modalBarrierColor: barrierColor,
     375           1 :       settings: RouteSettings(name: "bottomsheet"),
     376             :       enableDrag: enableDrag,
     377             :     ));
     378             :   }
     379             : 
     380           1 :   void rawSnackbar(
     381             :       {String title,
     382             :       String message,
     383             :       Widget titleText,
     384             :       Widget messageText,
     385             :       Widget icon,
     386             :       bool instantInit = false,
     387             :       bool shouldIconPulse = true,
     388             :       double maxWidth,
     389             :       EdgeInsets margin = const EdgeInsets.all(0.0),
     390             :       EdgeInsets padding = const EdgeInsets.all(16),
     391             :       double borderRadius = 0.0,
     392             :       Color borderColor,
     393             :       double borderWidth = 1.0,
     394             :       Color backgroundColor = const Color(0xFF303030),
     395             :       Color leftBarIndicatorColor,
     396             :       List<BoxShadow> boxShadows,
     397             :       Gradient backgroundGradient,
     398             :       FlatButton mainButton,
     399             :       OnTap onTap,
     400             :       Duration duration = const Duration(seconds: 3),
     401             :       bool isDismissible = true,
     402             :       SnackDismissDirection dismissDirection = SnackDismissDirection.VERTICAL,
     403             :       bool showProgressIndicator = false,
     404             :       AnimationController progressIndicatorController,
     405             :       Color progressIndicatorBackgroundColor,
     406             :       Animation<Color> progressIndicatorValueColor,
     407             :       SnackPosition snackPosition = SnackPosition.BOTTOM,
     408             :       SnackStyle snackStyle = SnackStyle.FLOATING,
     409             :       Curve forwardAnimationCurve = Curves.easeOutCirc,
     410             :       Curve reverseAnimationCurve = Curves.easeOutCirc,
     411             :       Duration animationDuration = const Duration(seconds: 1),
     412             :       SnackStatusCallback onStatusChanged,
     413             :       double barBlur = 0.0,
     414             :       double overlayBlur = 0.0,
     415             :       Color overlayColor = Colors.transparent,
     416             :       Form userInputForm}) {
     417           1 :     GetBar getBar = GetBar(
     418             :         title: title,
     419             :         message: message,
     420             :         titleText: titleText,
     421             :         messageText: messageText,
     422             :         snackPosition: snackPosition,
     423             :         borderRadius: borderRadius,
     424             :         margin: margin,
     425             :         duration: duration,
     426             :         barBlur: barBlur,
     427             :         backgroundColor: backgroundColor,
     428             :         icon: icon,
     429             :         shouldIconPulse: shouldIconPulse,
     430             :         maxWidth: maxWidth,
     431             :         padding: padding,
     432             :         borderColor: borderColor,
     433             :         borderWidth: borderWidth,
     434             :         leftBarIndicatorColor: leftBarIndicatorColor,
     435             :         boxShadows: boxShadows,
     436             :         backgroundGradient: backgroundGradient,
     437             :         mainButton: mainButton,
     438             :         onTap: onTap,
     439             :         isDismissible: isDismissible,
     440             :         dismissDirection: dismissDirection,
     441             :         showProgressIndicator: showProgressIndicator ?? false,
     442             :         progressIndicatorController: progressIndicatorController,
     443             :         progressIndicatorBackgroundColor: progressIndicatorBackgroundColor,
     444             :         progressIndicatorValueColor: progressIndicatorValueColor,
     445             :         snackStyle: snackStyle,
     446             :         forwardAnimationCurve: forwardAnimationCurve,
     447             :         reverseAnimationCurve: reverseAnimationCurve,
     448             :         animationDuration: animationDuration,
     449             :         overlayBlur: overlayBlur,
     450             :         overlayColor: overlayColor,
     451             :         userInputForm: userInputForm);
     452             : 
     453             :     if (instantInit) {
     454           1 :       getBar.show();
     455             :     } else {
     456           0 :       SchedulerBinding.instance.addPostFrameCallback((_) {
     457           0 :         getBar.show();
     458             :       });
     459             :     }
     460             :   }
     461             : 
     462           1 :   void snackbar(title, message,
     463             :       {Color colorText,
     464             :       Duration duration,
     465             : 
     466             :       /// with instantInit = false you can put snackbar on initState
     467             :       bool instantInit = true,
     468             :       SnackPosition snackPosition,
     469             :       Widget titleText,
     470             :       Widget messageText,
     471             :       Widget icon,
     472             :       bool shouldIconPulse,
     473             :       double maxWidth,
     474             :       EdgeInsets margin,
     475             :       EdgeInsets padding,
     476             :       double borderRadius,
     477             :       Color borderColor,
     478             :       double borderWidth,
     479             :       Color backgroundColor,
     480             :       Color leftBarIndicatorColor,
     481             :       List<BoxShadow> boxShadows,
     482             :       Gradient backgroundGradient,
     483             :       FlatButton mainButton,
     484             :       OnTap onTap,
     485             :       bool isDismissible,
     486             :       bool showProgressIndicator,
     487             :       SnackDismissDirection dismissDirection,
     488             :       AnimationController progressIndicatorController,
     489             :       Color progressIndicatorBackgroundColor,
     490             :       Animation<Color> progressIndicatorValueColor,
     491             :       SnackStyle snackStyle,
     492             :       Curve forwardAnimationCurve,
     493             :       Curve reverseAnimationCurve,
     494             :       Duration animationDuration,
     495             :       double barBlur,
     496             :       double overlayBlur,
     497             :       Color overlayColor,
     498             :       Form userInputForm}) {
     499           1 :     GetBar getBar = GetBar(
     500             :         titleText: (title == null)
     501             :             ? null
     502             :             : titleText ??
     503           1 :                 Text(
     504             :                   title,
     505           1 :                   style: TextStyle(
     506           3 :                       color: colorText ?? theme.iconTheme.color,
     507             :                       fontWeight: FontWeight.w800,
     508             :                       fontSize: 16),
     509             :                 ),
     510             :         messageText: messageText ??
     511           1 :             Text(
     512             :               message,
     513           1 :               style: TextStyle(
     514           3 :                   color: colorText ?? theme.iconTheme.color,
     515             :                   fontWeight: FontWeight.w300,
     516             :                   fontSize: 14),
     517             :             ),
     518             :         snackPosition: snackPosition ?? SnackPosition.TOP,
     519             :         borderRadius: borderRadius ?? 15,
     520           1 :         margin: margin ?? EdgeInsets.symmetric(horizontal: 10),
     521           0 :         duration: duration ?? Duration(seconds: 3),
     522             :         barBlur: barBlur ?? 7.0,
     523           1 :         backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2),
     524             :         icon: icon,
     525             :         shouldIconPulse: shouldIconPulse ?? true,
     526             :         maxWidth: maxWidth,
     527           1 :         padding: padding ?? EdgeInsets.all(16),
     528             :         borderColor: borderColor,
     529             :         borderWidth: borderWidth,
     530             :         leftBarIndicatorColor: leftBarIndicatorColor,
     531             :         boxShadows: boxShadows,
     532             :         backgroundGradient: backgroundGradient,
     533             :         mainButton: mainButton,
     534             :         onTap: onTap,
     535             :         isDismissible: isDismissible ?? true,
     536             :         dismissDirection: dismissDirection ?? SnackDismissDirection.VERTICAL,
     537             :         showProgressIndicator: showProgressIndicator ?? false,
     538             :         progressIndicatorController: progressIndicatorController,
     539             :         progressIndicatorBackgroundColor: progressIndicatorBackgroundColor,
     540             :         progressIndicatorValueColor: progressIndicatorValueColor,
     541             :         snackStyle: snackStyle ?? SnackStyle.FLOATING,
     542             :         forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc,
     543             :         reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc,
     544           1 :         animationDuration: animationDuration ?? Duration(seconds: 1),
     545             :         overlayBlur: overlayBlur ?? 0.0,
     546             :         overlayColor: overlayColor ?? Colors.transparent,
     547             :         userInputForm: userInputForm);
     548             : 
     549             :     if (instantInit) {
     550           1 :       getBar.show();
     551             :     } else {
     552           0 :       _routing.isSnackbar = true;
     553           0 :       SchedulerBinding.instance.addPostFrameCallback((_) {
     554           0 :         getBar.show();
     555             :       });
     556             :     }
     557             :   }
     558             : 
     559             :   /// change default config of Get
     560           3 :   config(
     561             :       {bool enableLog,
     562             :       bool defaultPopGesture,
     563             :       bool defaultOpaqueRoute,
     564             :       Duration defaultDurationTransition,
     565             :       bool defaultGlobalState,
     566             :       Transition defaultTransition}) {
     567             :     if (enableLog != null) {
     568             :       enableLog = enableLog;
     569             :     }
     570             :     if (defaultPopGesture != null) {
     571             :       defaultPopGesture = defaultPopGesture;
     572             :     }
     573             :     if (defaultOpaqueRoute != null) {
     574             :       defaultOpaqueRoute = defaultOpaqueRoute;
     575             :     }
     576             :     if (defaultTransition != null) {
     577             :       defaultTransition = defaultTransition;
     578             :     }
     579             : 
     580             :     if (defaultDurationTransition != null) {
     581             :       defaultDurationTransition = defaultDurationTransition;
     582             :     }
     583             : 
     584             :     if (defaultGlobalState != null) {
     585             :       defaultGlobalState = defaultGlobalState;
     586             :     }
     587             :   }
     588             : 
     589             :   GetMaterialController getController = GetMaterialController();
     590             : 
     591           0 :   changeTheme(ThemeData theme) {
     592           0 :     getController.setTheme(theme);
     593             :   }
     594             : 
     595           0 :   changeThemeMode(ThemeMode themeMode) {
     596           0 :     getController.setThemeMode(themeMode);
     597             :   }
     598             : 
     599           0 :   GlobalKey<NavigatorState> addKey(GlobalKey<NavigatorState> newKey) {
     600           0 :     key = newKey;
     601           0 :     return key;
     602             :   }
     603             : 
     604             :   GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
     605             : 
     606             :   Map<int, GlobalKey<NavigatorState>> _keys = {};
     607             : 
     608           0 :   GlobalKey<NavigatorState> nestedKey(int key) {
     609           0 :     _keys.putIfAbsent(key, () => GlobalKey<NavigatorState>());
     610           0 :     return _keys[key];
     611             :   }
     612             : 
     613           3 :   GlobalKey<NavigatorState> global(int k) {
     614             :     if (k == null) {
     615           3 :       return key;
     616             :     }
     617           0 :     if (!_keys.containsKey(k)) {
     618             :       throw 'route id not found';
     619             :     }
     620           0 :     return _keys[k];
     621             :   }
     622             : 
     623             :   /// give access to Routing API from GetObserver
     624           0 :   Routing get routing => _routing;
     625             : 
     626           0 :   RouteSettings get routeSettings => settings;
     627             : 
     628             :   Routing _routing = Routing();
     629             : 
     630             :   Map<String, String> _parameters = {};
     631             : 
     632           1 :   setParameter(Map<String, String> param) {
     633           1 :     _parameters = param;
     634             :   }
     635             : 
     636           3 :   setRouting(Routing rt) {
     637           3 :     _routing = rt;
     638             :   }
     639             : 
     640           1 :   setSettings(RouteSettings settings) {
     641             :     settings = settings;
     642             :   }
     643             : 
     644             :   /// give current arguments
     645           0 :   Object get arguments => _routing.args;
     646             : 
     647             :   /// give current arguments
     648           0 :   Map<String, String> get parameters => _parameters;
     649             : 
     650             :   /// give name from current route
     651           0 :   get currentRoute => _routing.current;
     652             : 
     653             :   /// give name from previous route
     654           0 :   get previousRoute => _routing.previous;
     655             : 
     656             :   /// check if snackbar is open
     657           3 :   bool get isSnackbarOpen => _routing.isSnackbar;
     658             : 
     659             :   /// check if dialog is open
     660           3 :   bool get isDialogOpen => _routing.isDialog;
     661             : 
     662             :   /// check if bottomsheet is open
     663           3 :   bool get isBottomSheetOpen => _routing.isBottomSheet;
     664             : 
     665             :   /// check a raw current route
     666           0 :   Route<dynamic> get rawRoute => _routing.route;
     667             : 
     668             :   /// check if popGesture is enable
     669           6 :   bool get isPopGestureEnable => defaultPopGesture;
     670             : 
     671             :   /// check if default opaque route is enable
     672           6 :   bool get isOpaqueRouteDefault => defaultOpaqueRoute;
     673             : 
     674             :   /// give access to currentContext
     675           6 :   BuildContext get context => key.currentContext;
     676             : 
     677             :   /// give access to current Overlay Context
     678          10 :   BuildContext get overlayContext => key.currentState.overlay.context;
     679             : 
     680             :   /// give access to Theme.of(context)
     681           6 :   ThemeData get theme => Theme.of(context);
     682             : 
     683             :   /// give access to TextTheme.of(context)
     684           0 :   TextTheme get textTheme => Theme.of(context).textTheme;
     685             : 
     686             :   /// give access to Mediaquery.of(context)
     687           0 :   MediaQueryData get mediaQuery => MediaQuery.of(context);
     688             : 
     689             :   /// Check if dark mode theme is enable
     690           0 :   get isDarkMode => (theme.brightness == Brightness.dark);
     691             : 
     692             :   /// Check if dark mode theme is enable on platform on android Q+
     693           0 :   get isPlatformDarkMode => (mediaQuery.platformBrightness == Brightness.dark);
     694             : 
     695             :   /// give access to Theme.of(context).iconTheme.color
     696           0 :   Color get iconColor => Theme.of(context).iconTheme.color;
     697             : 
     698             :   /// give access to FocusScope.of(context)
     699           0 :   FocusNode get focusScope => FocusManager.instance.primaryFocus;
     700             : 
     701             :   /// give access to Immutable MediaQuery.of(context).size.height
     702           0 :   double get height => MediaQuery.of(context).size.height;
     703             : 
     704             :   /// give access to Immutable MediaQuery.of(context).size.width
     705           0 :   double get width => MediaQuery.of(context).size.width;
     706             : }
     707             : 
     708             : /// It replaces the Flutter Navigator, but needs no context.
     709             : /// You can to use navigator.push(YourRoute()) rather Navigator.push(context, YourRoute());
     710           0 : NavigatorState get navigator => Get.key.currentState;

Generated by: LCOV version 1.14