LoadingDialogWidget.dart 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:flutter/material.dart';
  2. ///Loading弹窗
  3. ///网络请求等场景使用
  4. class LoadingDialogWidget extends StatelessWidget {
  5. bool dismissible = false;
  6. LoadingDialogWidget({Key? key, required this.dismissible}) : super(key: key);
  7. @override
  8. Widget build(BuildContext context) {
  9. return Stack(
  10. alignment: Alignment.center,
  11. children: [
  12. ///拦截返回导航
  13. WillPopScope(
  14. child: Container(
  15. decoration: BoxDecoration(
  16. borderRadius: BorderRadius.circular(4),
  17. color: Colors.grey[200]),
  18. padding: const EdgeInsets.all(20),
  19. height: 80,
  20. width: 80,
  21. child: CircularProgressIndicator(
  22. color: Theme.of(context).primaryColor,
  23. backgroundColor: Colors.grey[300],
  24. ),
  25. ),
  26. ///拦截返回按钮:false = 不允许通过返回按钮关闭弹窗
  27. onWillPop: () => Future.value(dismissible))
  28. ],
  29. );
  30. }
  31. }