snackbar method

SnackbarController snackbar(
  1. String title,
  2. String message, {
  3. Color? colorText,
  4. Duration? duration = const Duration(seconds: 3),
  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. TextButton? mainButton,
  22. OnTap? onTap,
  23. OnHover? onHover,
  24. bool? isDismissible,
  25. bool? showProgressIndicator,
  26. DismissDirection? dismissDirection,
  27. AnimationController? progressIndicatorController,
  28. Color? progressIndicatorBackgroundColor,
  29. Animation<Color>? progressIndicatorValueColor,
  30. SnackStyle? snackStyle,
  31. Curve? forwardAnimationCurve,
  32. Curve? reverseAnimationCurve,
  33. Duration? animationDuration,
  34. double? barBlur,
  35. double? overlayBlur,
  36. SnackbarStatusCallback? snackbarStatus,
  37. Color? overlayColor,
  38. Form? userInputForm,
})

Implementation

SnackbarController snackbar(
  String title,
  String message, {
  Color? colorText,
  Duration? duration = const Duration(seconds: 3),

  /// 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,
  TextButton? mainButton,
  OnTap? onTap,
  OnHover? onHover,
  bool? isDismissible,
  bool? showProgressIndicator,
  DismissDirection? 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,
}) {
  final getSnackBar = GetSnackBar(
      snackbarStatus: snackbarStatus,
      titleText: 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 ?? const EdgeInsets.symmetric(horizontal: 10),
      duration: duration,
      barBlur: barBlur ?? 7.0,
      backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2),
      icon: icon,
      shouldIconPulse: shouldIconPulse ?? true,
      maxWidth: maxWidth,
      padding: padding ?? const EdgeInsets.all(16),
      borderColor: borderColor,
      borderWidth: borderWidth,
      leftBarIndicatorColor: leftBarIndicatorColor,
      boxShadows: boxShadows,
      backgroundGradient: backgroundGradient,
      mainButton: mainButton,
      onTap: onTap,
      onHover: onHover,
      isDismissible: isDismissible ?? true,
      dismissDirection: dismissDirection,
      showProgressIndicator: showProgressIndicator ?? false,
      progressIndicatorController: progressIndicatorController,
      progressIndicatorBackgroundColor: progressIndicatorBackgroundColor,
      progressIndicatorValueColor: progressIndicatorValueColor,
      snackStyle: snackStyle ?? SnackStyle.floating,
      forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc,
      reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc,
      animationDuration: animationDuration ?? const Duration(seconds: 1),
      overlayBlur: overlayBlur ?? 0.0,
      overlayColor: overlayColor ?? Colors.transparent,
      userInputForm: userInputForm);

  final controller = SnackbarController(getSnackBar);

  if (instantInit) {
    controller.show();
  } else {
    //routing.isSnackbar = true;
    ambiguate(Engine.instance)!.addPostFrameCallback((_) {
      controller.show();
    });
  }
  return controller;
}