LCOV - code coverage report
Current view: top level - src - get_main.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 119 189 63.0 %
Date: 2020-06-23 02:32:54 Functions: 0 0 -

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

Generated by: LCOV version 1.14