showLoading static method
void
showLoading({
- required BuildContext context,
- Color bgColor = Colors.transparent,
- String? text,
- Widget? child,
- bool isClickDismiss = false,
- OnClickDismiss? onClickDismiss,
- Duration fadeDuration = const Duration(milliseconds: 350),
Implementation
static void showLoading({
required BuildContext context,
Color bgColor=Colors.transparent,
String? text,
Widget? child,
bool isClickDismiss = false,
OnClickDismiss? onClickDismiss,
Duration fadeDuration = const Duration(milliseconds: 350),
}) {
hideLoading();
child ??= _DefaultLoadingWidget(msg: text ?? "加载中...");
_LoadingStateFul newChild = _LoadingStateFul(
fadeDuration: fadeDuration,
isClickDismiss: isClickDismiss,
onDismiss: () {
if(onClickDismiss != null){
onClickDismiss();
}
hideLoading();
},
bgColor: bgColor,
child: child,
);
_entry = OverlayEntry(builder: (context) {
return newChild;
});
try {
OverlayState overlay = Overlay.of(context);
overlay.insert(_entry!);
} catch (err) {
hideLoading();
}
}