showError static method

void showError(
  1. BuildContext context,
  2. String message, {
  3. Duration duration = const Duration(seconds: 3),
  4. VoidCallback? onRetry,
})

显示错误提示

Implementation

static void showError(
  BuildContext context,
  String message, {
  Duration duration = const Duration(seconds: 3),
  VoidCallback? onRetry,
}) {
  _showToast(
    context,
    message,
    icon: Icons.error_outline,
    iconColor: const Color(0xFFE53935),
    backgroundColor: const Color(0xFFFEF5F5),
    textColor: const Color(0xFFC62828),
    duration: duration,
    action: onRetry != null
        ? SnackBarAction(
            label: '重试',
            textColor: const Color(0xFFE53935),
            onPressed: onRetry,
          )
        : null,
  );
}