snackbar method

void snackbar(
  1. String title,
  2. String message,
  3. {Color colorText,
  4. Duration duration,
  5. bool instantInit = true,
  6. SnackPosition snackPosition,
  7. Widget titleText,
  8. Widget messageText,
  9. Widget icon,
  10. bool shouldIconPulse,
  11. double maxWidth,
  12. EdgeInsets margin,
  13. EdgeInsets padding,
  14. double borderRadius,
  15. Color borderColor,
  16. double borderWidth,
  17. Color backgroundColor,
  18. Color leftBarIndicatorColor,
  19. List<BoxShadow> boxShadows,
  20. Gradient backgroundGradient,
  21. FlatButton mainButton,
  22. OnTap onTap,
  23. bool isDismissible,
  24. bool showProgressIndicator,
  25. SnackDismissDirection dismissDirection,
  26. AnimationController progressIndicatorController,
  27. Color progressIndicatorBackgroundColor,
  28. Animation<Color> progressIndicatorValueColor,
  29. SnackStyle snackStyle,
  30. Curve forwardAnimationCurve,
  31. Curve reverseAnimationCurve,
  32. Duration animationDuration,
  33. double barBlur,
  34. double overlayBlur,
  35. SnackbarStatusCallback snackbarStatus,
  36. Color overlayColor,
  37. Form userInputForm}
)

Implementation

void snackbar(
  String title,
  String message, {
  Color colorText,
  Duration duration,

  /// with instantInit = false you can put snackbar on initState
  bool instantInit = true,
  SnackPosition snackPosition,
  Widget titleText,
  Widget messageText,
  Widget icon,
  bool shouldIconPulse,
  double maxWidth,
  EdgeInsets margin,
  EdgeInsets padding,
  double borderRadius,
  Color borderColor,
  double borderWidth,
  Color backgroundColor,
  Color leftBarIndicatorColor,
  List<BoxShadow> boxShadows,
  Gradient backgroundGradient,
  FlatButton mainButton,
  OnTap onTap,
  bool isDismissible,
  bool showProgressIndicator,
  SnackDismissDirection dismissDirection,
  AnimationController progressIndicatorController,
  Color progressIndicatorBackgroundColor,
  Animation<Color> progressIndicatorValueColor,
  SnackStyle snackStyle,
  Curve forwardAnimationCurve,
  Curve reverseAnimationCurve,
  Duration animationDuration,
  double barBlur,
  double overlayBlur,
  SnackbarStatusCallback snackbarStatus,
  Color overlayColor,
  Form userInputForm,
}) async {
  final getBar = GetBar(
      snackbarStatus: snackbarStatus,
      titleText: (title == null)
          ? null
          : titleText ??
              Text(
                title,
                style: TextStyle(
                  color: colorText ?? iconColor ?? Colors.black,
                  fontWeight: FontWeight.w800,
                  fontSize: 16,
                ),
              ),
      messageText: messageText ??
          Text(
            message,
            style: TextStyle(
              color: colorText ?? iconColor ?? Colors.black,
              fontWeight: FontWeight.w300,
              fontSize: 14,
            ),
          ),
      snackPosition: snackPosition ?? SnackPosition.TOP,
      borderRadius: borderRadius ?? 15,
      margin: margin ?? EdgeInsets.symmetric(horizontal: 10),
      duration: duration ?? Duration(seconds: 3),
      barBlur: barBlur ?? 7.0,
      backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2),
      icon: icon,
      shouldIconPulse: shouldIconPulse ?? true,
      maxWidth: maxWidth,
      padding: padding ?? EdgeInsets.all(16),
      borderColor: borderColor,
      borderWidth: borderWidth,
      leftBarIndicatorColor: leftBarIndicatorColor,
      boxShadows: boxShadows,
      backgroundGradient: backgroundGradient,
      mainButton: mainButton,
      onTap: onTap,
      isDismissible: isDismissible ?? true,
      dismissDirection: dismissDirection ?? SnackDismissDirection.VERTICAL,
      showProgressIndicator: showProgressIndicator ?? false,
      progressIndicatorController: progressIndicatorController,
      progressIndicatorBackgroundColor: progressIndicatorBackgroundColor,
      progressIndicatorValueColor: progressIndicatorValueColor,
      snackStyle: snackStyle ?? SnackStyle.FLOATING,
      forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc,
      reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc,
      animationDuration: animationDuration ?? Duration(seconds: 1),
      overlayBlur: overlayBlur ?? 0.0,
      overlayColor: overlayColor ?? Colors.transparent,
      userInputForm: userInputForm);

  if (instantInit) {
    showSnackbar(getBar);
  } else {
    routing.isSnackbar = true;
    SchedulerBinding.instance.addPostFrameCallback((_) {
      showSnackbar(getBar);
    });
  }
}