showToast method

void showToast(
  1. String message, {
  2. Duration? duration,
  3. bool clearOldToasts = true,
  4. void onPressed()?,
  5. String? actionLabel,
})

Implementation

void showToast(
  String message, {
  Duration? duration,
  bool clearOldToasts = true,
  void Function()? onPressed,
  String? actionLabel,
}) {
  if (clearOldToasts) {
    ScaffoldMessenger.of(this).clearSnackBars();
  }
  ScaffoldMessenger.of(this).showSnackBar(
    SnackBar(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(10),
      ),
      behavior: SnackBarBehavior.floating,
      elevation: 0,
      content: Text(
        message,
        style: TextStyle(
          fontFamily: theme.textTheme.bodyMedium?.fontFamily,
        ),
      ),
      duration: duration ?? const Duration(seconds: 3),
      action: onPressed != null
          ? SnackBarAction(
              label: actionLabel ?? jetI10n.retry,
              onPressed: onPressed,
            )
          : null,
    ),
  );
}