showWarning static method

void showWarning(
  1. BuildContext context,
  2. String message, {
  3. Duration duration = const Duration(seconds: 2),
})

Shows a warning snackbar with a warning icon.

Implementation

static void showWarning(
  BuildContext context,
  String message, {
  Duration duration = const Duration(seconds: 2),
}) {
  ScaffoldMessenger.of(context).showSnackBar(
    SnackBar(
      content: Row(
        children: [
          const Icon(Icons.warning_amber, color: Colors.white),
          const SizedBox(width: 12),
          Expanded(child: Text(message)),
        ],
      ),
      backgroundColor: Colors.orange.shade600,
      behavior: SnackBarBehavior.floating,
      duration: duration,
    ),
  );
}