Template
Core 基础设施:Flavor 三包体系、Drift+SQLCipher 加密数据库 7 拦截器 Dio 网络栈、CrashReporter 崩溃日志、Sealed Failure 错误体系 5 色板主题系统、Auth 认证骨架(Clean Architecture)、Dev Panel、Mock Adapter 通过验证:flutter analyze(0 errors)、flutter test(全绿)、staging APK 74.8MB
48 lines
1.2 KiB
Dart
48 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// 错误状态视图,提供重试按钮。
|
|
class ErrorView extends StatelessWidget {
|
|
const ErrorView({
|
|
super.key,
|
|
this.message = '加载失败,请重试',
|
|
this.onRetry,
|
|
});
|
|
|
|
final String message;
|
|
final VoidCallback? onRetry;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(32),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(
|
|
Icons.error_outline,
|
|
size: 56,
|
|
color: Theme.of(context).colorScheme.error,
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
message,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
if (onRetry != null) ...[
|
|
const SizedBox(height: 24),
|
|
FilledButton.tonal(
|
|
onPressed: onRetry,
|
|
child: const Text('重试'),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|