showToast static method

void showToast(
  1. String message, {
  2. BuildContext? context,
  3. ToastType type = ToastType.info,
  4. ToastPosition position = ToastPosition.top,
  5. Duration duration = const Duration(seconds: 2),
  6. String? title,
  7. bool showCloseIcon = true,
  8. ToastAnimation animation = ToastAnimation.none,
  9. TextStyle? messageStyle,
  10. TextStyle? titleStyle,
  11. EdgeInsetsGeometry? padding,
  12. double borderRadius = 8.0,
  13. double elevation = 0.0,
  14. Widget? icon,
  15. Color? backgroundColor,
  16. VoidCallback? onTap,
  17. double? progress,
  18. bool showIndicator = false,
})

====================================================== SHOW TOAST

Example:

TfkToast.showToast(
  "Order placed successfully",
  type: ToastType.success,
);

======================================================

Implementation

static void showToast(
  String message, {
  BuildContext? context,
  ToastType type = ToastType.info,
  ToastPosition position = ToastPosition.top,
  Duration duration = const Duration(seconds: 2),
  String? title,
  bool showCloseIcon = true,
  ToastAnimation animation = ToastAnimation.none,
  TextStyle? messageStyle,
  TextStyle? titleStyle,
  EdgeInsetsGeometry? padding,
  double borderRadius = 8.0,
  double elevation = 0.0,
  Widget? icon,
  Color? backgroundColor,
  VoidCallback? onTap,
  double? progress,
  bool showIndicator = false,
}) {
  _toastQueue.add(
    ToastEntry(
      message: message,
      type: type,
      position: position,
      duration: duration,
      title: title,
      showCloseIcon: showCloseIcon,
      animation: animation,
      messageStyle: messageStyle,
      titleStyle: titleStyle,
      padding: padding,
      borderRadius: borderRadius,
      elevation: elevation,
      icon: icon,
      backgroundColor: backgroundColor,
      onTap: onTap,
      progress: progress,
      showIndicator: showIndicator,
    ),
  );

  if (!_isToastActive) {
    _showNextToast(context);
  }
}