62 lines
1.6 KiB
Dart
62 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Empty state widget
|
|
class EmptyState extends StatelessWidget {
|
|
final String message;
|
|
final String? subMessage;
|
|
final IconData? icon;
|
|
final VoidCallback? onAction;
|
|
final String? actionText;
|
|
|
|
const EmptyState({
|
|
super.key,
|
|
required this.message,
|
|
this.subMessage,
|
|
this.icon,
|
|
this.onAction,
|
|
this.actionText,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(32.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
icon ?? Icons.inbox_outlined,
|
|
size: 48,
|
|
color: Theme.of(context).colorScheme.outline,
|
|
),
|
|
const SizedBox(height: 24),
|
|
Text(
|
|
message,
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
if (subMessage != null) ...[
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
subMessage!,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
if (onAction != null) ...[
|
|
const SizedBox(height: 24),
|
|
ElevatedButton(
|
|
onPressed: onAction,
|
|
child: Text(actionText ?? 'Take Action'),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|