52 lines
1.4 KiB
Dart
52 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// 各主页面共用的占位内容:一个图标、一句标题和可选说明。
|
|
///
|
|
/// 页面接上真实业务后可以直接替换掉。
|
|
class EmptyState extends StatelessWidget {
|
|
const EmptyState({
|
|
required this.icon,
|
|
required this.title,
|
|
this.message,
|
|
super.key,
|
|
});
|
|
|
|
final IconData icon;
|
|
final String title;
|
|
final String? message;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ThemeData theme = Theme.of(context);
|
|
final String? message = this.message;
|
|
|
|
return Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Icon(icon, size: 56, color: theme.colorScheme.primary),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
title,
|
|
style: theme.textTheme.titleMedium,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
if (message != null) ...<Widget>[
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
message,
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
color: theme.colorScheme.onSurfaceVariant,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|