Files
2026-07-27 14:42:23 +02:00

39 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
import '../theme/theme_x.dart';
/// Inline error state for a failed fetch — an `AsyncValue.error` case in a
/// screen body. Deliberately takes a plain [message] string rather than an
/// `ApiException` so `core/widgets` has no dependency on `core/network`;
/// callers resolve `exception.userMessage` before passing it in.
class ErrorBanner extends StatelessWidget {
const ErrorBanner({super.key, required this.message, this.onRetry});
final String message;
final VoidCallback? onRetry;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: Color.alphaBlend(context.status.critical.withValues(alpha: 0.08), context.colors.surface),
borderRadius: BorderRadius.circular(10),
border: Border.all(color: context.status.critical.withValues(alpha: 0.4)),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.error_outline, size: 18, color: context.status.critical),
const SizedBox(width: 12),
Expanded(child: Text(message, style: context.text.bodyMedium)),
if (onRetry != null) ...[
const SizedBox(width: 12),
TextButton(onPressed: onRetry, child: const Text('Retry')),
],
],
),
);
}
}