showErrorWidget function
Implementation
Widget showErrorWidget({
required String errorMessage,
VoidCallback? onRetry,
}) {
return Center(
child: Container(
margin: const EdgeInsets.all(20),
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.red.shade50,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.red.shade200),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.error_outline,
color: Colors.red.shade400,
size: 48,
),
const SizedBox(height: 16),
Text(
errorMessage,
style: TextStyle(
color: Colors.red.shade700,
fontSize: 15,
fontWeight: FontWeight.w500,
fontFamily: primaryFontFamily,
),
textAlign: TextAlign.center,
maxLines: 5,
),
if (onRetry != null) ...[
const SizedBox(height: 20),
ElevatedButton.icon(
onPressed: onRetry,
icon: const Icon(Icons.refresh, color: Colors.white, size: 18),
label: const Text(
'Retry',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: CommonColors.primary,
foregroundColor: Colors.white,
elevation: 2,
shadowColor: CommonColors.primary.withValues(alpha: 0.3),
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
],
],
),
),
);
}