基础库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

44 lines
880 B

  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. import 'loading_dialog.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. }