| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import 'package:flutter/material.dart';
-
- /// 空状态占位组件
- class EmptyState extends StatelessWidget {
- final IconData icon;
- final String title;
- final String? subtitle;
- final Widget? action;
-
- const EmptyState({
- super.key,
- this.icon = Icons.inbox_outlined,
- required this.title,
- this.subtitle,
- this.action,
- });
-
- @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.shade400),
- const SizedBox(height: 16),
- Text(title, style: TextStyle(fontSize: 16, color: Colors.grey.shade700)),
- if (subtitle != null) ...[
- const SizedBox(height: 8),
- Text(subtitle!, style: TextStyle(fontSize: 13, color: Colors.grey.shade500)),
- ],
- if (action != null) ...[
- const SizedBox(height: 24),
- action!,
- ],
- ],
- ),
- ),
- );
- }
- }
|