智慧水务管理系统 - 精河县供水工程综合管理平台

loading_overlay.dart 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import 'package:flutter/material.dart';
  2. /// 加载遮罩组件
  3. class LoadingOverlay extends StatelessWidget {
  4. final bool isLoading;
  5. final Widget child;
  6. final String? message;
  7. const LoadingOverlay({
  8. super.key,
  9. required this.isLoading,
  10. required this.child,
  11. this.message,
  12. });
  13. @override
  14. Widget build(BuildContext context) {
  15. return Stack(
  16. children: [
  17. child,
  18. if (isLoading)
  19. Container(
  20. color: Colors.black.withOpacity(0.3),
  21. child: Center(
  22. child: Card(
  23. child: Padding(
  24. padding: const EdgeInsets.all(24),
  25. child: Column(
  26. mainAxisSize: MainAxisSize.min,
  27. children: [
  28. const CircularProgressIndicator(),
  29. if (message != null) ...[
  30. const SizedBox(height: 16),
  31. Text(message!),
  32. ],
  33. ],
  34. ),
  35. ),
  36. ),
  37. ),
  38. ),
  39. ],
  40. );
  41. }
  42. }