card static method
Widget
card({
- required BuildContext context,
- required Exception error,
- required VoidCallback onRetry,
- String? title,
- String? message,
- double? elevation,
Creates a card-style error widget with shadow and rounded corners
Good for grid views or when you want a distinct error card
Implementation
static Widget card({
required BuildContext context,
required Exception error,
required VoidCallback onRetry,
String? title,
String? message,
double? elevation,
}) {
return Center(
child: Card(
margin: const EdgeInsets.all(16.0),
elevation: elevation ?? 4,
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.warning_amber_rounded,
color: Colors.orange,
size: 48,
),
const SizedBox(height: 16),
Text(
title ?? 'Error Loading Data',
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
Text(
message ?? 'An error occurred while loading the data.',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Colors.grey[600],
),
),
const SizedBox(height: 16),
OutlinedButton.icon(
onPressed: onRetry,
icon: const Icon(Icons.refresh),
label: const Text('Retry'),
),
],
),
),
),
);
}