47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
class AppEmptyView extends StatelessWidget {
|
|
const AppEmptyView({
|
|
super.key,
|
|
this.title = '暂无数据',
|
|
this.message,
|
|
this.icon = Icons.inbox_outlined,
|
|
this.action,
|
|
});
|
|
|
|
final String title;
|
|
final String? message;
|
|
final IconData icon;
|
|
final Widget? action;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colors = Theme.of(context).colorScheme;
|
|
return Center(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(24.r),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(icon, size: 56.r, color: colors.outline),
|
|
SizedBox(height: 12.h),
|
|
Text(title, style: Theme.of(context).textTheme.titleMedium),
|
|
if (message != null) ...[
|
|
SizedBox(height: 6.h),
|
|
Text(
|
|
message!,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
if (action != null) ...[SizedBox(height: 16.h), action!],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|