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
58 lines
1.4 KiB
Dart
58 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// 全屏/局部 loading 遮罩。
|
|
///
|
|
/// 用法:
|
|
/// ```dart
|
|
/// LoadingOverlay(
|
|
/// loading: _isLoading,
|
|
/// child: MyWidget(),
|
|
/// )
|
|
/// ```
|
|
class LoadingOverlay extends StatelessWidget {
|
|
const LoadingOverlay({
|
|
super.key,
|
|
required this.child,
|
|
this.loading = false,
|
|
this.label,
|
|
});
|
|
|
|
final Widget child;
|
|
final bool loading;
|
|
final String? label;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Stack(
|
|
children: [
|
|
child,
|
|
if (loading)
|
|
Positioned.fill(
|
|
child: ColoredBox(
|
|
color: Colors.black26,
|
|
child: Center(
|
|
child: Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 32, vertical: 24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const CircularProgressIndicator(),
|
|
if (label != null) ...[
|
|
const SizedBox(height: 12),
|
|
Text(label!,
|
|
style: Theme.of(context).textTheme.bodySmall),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|