loading_overlay.dart 685 B

123456789101112131415161718192021222324252627
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:chicken_farm/core/utils/loading.dart';
  4. class LoadingOverlay extends ConsumerWidget {
  5. final Widget child;
  6. const LoadingOverlay({super.key, required this.child});
  7. @override
  8. Widget build(BuildContext context, WidgetRef ref) {
  9. final isLoading = ref.watch(loadingProvider);
  10. return Stack(
  11. children: [
  12. child,
  13. if (isLoading)
  14. Container(
  15. color: Colors.black.withValues(alpha: 0.5),
  16. child: const Center(
  17. child: CircularProgressIndicator(),
  18. ),
  19. ),
  20. ],
  21. );
  22. }
  23. }