Files
water-management-system/mobile-app/lib/shared/widgets/empty_state.dart
T

49 lines
1.2 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
/// 空状态组件
class EmptyState extends StatelessWidget {
final IconData icon;
final String message;
final String? actionLabel;
final VoidCallback? onAction;
const EmptyState({
super.key,
this.icon = Icons.inbox,
required this.message,
this.actionLabel,
this.onAction,
});
@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.all(32),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 64, color: Colors.grey[400]),
const SizedBox(height: 16),
Text(
message,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Colors.grey[600],
),
),
if (actionLabel != null && onAction != null) ...[
const SizedBox(height: 16),
ElevatedButton(
onPressed: onAction,
child: Text(actionLabel!),
),
],
],
),
),
);
}
}