Files
oott/frontend/lib/widgets/empty_state.dart
T

52 lines
1.5 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import '../theme/dimens.dart';
/// A centered placeholder for "nothing here yet" situations: an icon, a short
/// message and an optional call-to-action button. Keeps empty screens
/// consistent and gives the user a next step instead of a bare line of text.
class EmptyState extends StatelessWidget {
const EmptyState({
required this.icon,
required this.message,
this.actionLabel,
this.onAction,
super.key,
});
final IconData icon;
final String message;
final String? actionLabel;
final VoidCallback? onAction;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final hasAction = actionLabel != null && onAction != null;
return Center(
child: Padding(
padding: const EdgeInsets.all(Insets.xxl),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 48, color: theme.colorScheme.onSurfaceVariant),
const SizedBox(height: Insets.md),
Text(
message,
textAlign: TextAlign.center,
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
if (hasAction) ...[
const SizedBox(height: Insets.lg),
OutlinedButton(onPressed: onAction, child: Text(actionLabel!)),
],
],
),
),
);
}
}