智慧水务管理系统 - 精河县供水工程综合管理平台

empty_state.dart 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import 'package:flutter/material.dart';
  2. /// 空状态组件
  3. class EmptyState extends StatelessWidget {
  4. final IconData icon;
  5. final String message;
  6. final String? actionLabel;
  7. final VoidCallback? onAction;
  8. const EmptyState({
  9. super.key,
  10. this.icon = Icons.inbox,
  11. required this.message,
  12. this.actionLabel,
  13. this.onAction,
  14. });
  15. @override
  16. Widget build(BuildContext context) {
  17. return Center(
  18. child: Padding(
  19. padding: const EdgeInsets.all(32),
  20. child: Column(
  21. mainAxisSize: MainAxisSize.min,
  22. children: [
  23. Icon(icon, size: 64, color: Colors.grey[400]),
  24. const SizedBox(height: 16),
  25. Text(
  26. message,
  27. textAlign: TextAlign.center,
  28. style: TextStyle(
  29. fontSize: 16,
  30. color: Colors.grey[600],
  31. ),
  32. ),
  33. if (actionLabel != null && onAction != null) ...[
  34. const SizedBox(height: 16),
  35. ElevatedButton(
  36. onPressed: onAction,
  37. child: Text(actionLabel!),
  38. ),
  39. ],
  40. ],
  41. ),
  42. ),
  43. );
  44. }
  45. }