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

Generated by: LCOV version 1.14