基础组件库
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

loading.dart 922 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart';
  3. import 'package:zhiying_comm/zhiying_comm.dart';
  4. // loading弹窗
  5. class Loading {
  6. static OverlayEntry _overlayEntry;
  7. static Future show(
  8. BuildContext context, {
  9. String msg,
  10. }) async {
  11. dismiss();
  12. _overlayEntry = new OverlayEntry(builder: (context) {
  13. return GestureDetector(
  14. onTap: dismiss,
  15. child: Container(
  16. color: Colors.black.withOpacity(0.3),
  17. child: LoadingDialog(
  18. message: msg,
  19. ),
  20. ),
  21. );
  22. });
  23. try {
  24. //插入到 Overlay中显示 OverlayEntry
  25. Overlay.of(context).insert(_overlayEntry);
  26. }catch(e, s){
  27. Logger.error(e, s);
  28. }
  29. }
  30. static dismiss() {
  31. try {
  32. _overlayEntry?.remove();
  33. _overlayEntry = null;
  34. }catch(e, s){
  35. Logger.error(e, s);
  36. }
  37. }
  38. }