import 'package:flutter/material.dart'; import 'package:zhiying_base_widget/dialog/loading/loading_dialog.dart'; // loading弹窗 class Loading { static OverlayEntry _overlayEntry; static Future show( BuildContext context, { String msg, }) async { dismiss(); _overlayEntry = new OverlayEntry(builder: (context) { return GestureDetector( onTap: dismiss, child: Container( color: Colors.black.withOpacity(0.5), child: LoadingDialog( message: msg, ), ), ); }); //插入到 Overlay中显示 OverlayEntry Overlay.of(context).insert(_overlayEntry); } static dismiss() { _overlayEntry?.remove(); _overlayEntry = null; } }