showLoading method
dynamic
showLoading(
- BuildContext context, {
- String? text,
- JJLoadingType loadingType = JJLoadingType.circularLoading,
- Color color = Colors.white,
- Color backgroundColor = Colors.black54,
- double width = 100,
- double height = 100,
- double radius = 20,
- dynamic textStyle = const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w400),
添加loading
Implementation
showLoading(BuildContext context, {
String? text,
JJLoadingType loadingType = JJLoadingType.circularLoading,
Color color = Colors.white,
Color backgroundColor = Colors.black54,
double width = 100,
double height = 100,
double radius = 20,
textStyle = const TextStyle(color: Colors.white, fontSize: 14, fontWeight:FontWeight.w400),
}) async {
OverlayState? overlayState = Overlay.of(context);
if (_overlayEntry == null) {
_overlayEntry = OverlayEntry(builder: (context) {
_loading ??= JJLoading(
initialText: text,
textStyle: textStyle,
loadingType: loadingType,
color: color,
backgroundColor: backgroundColor,
);
return _loadingContent(_loading!, width: width, height: height, radius: radius, backgroundColor: backgroundColor,);
});
!_isShowing ? overlayState.insert(_overlayEntry!) : null;
} else {
!_isShowing ? _overlayEntry?.markNeedsBuild() : null;
}
_isShowing = true;
await Future.delayed(Duration(seconds: maxSeconds)).then((value) {
_overlayEntry?.remove();
_overlayEntry = null;
_loading = null;
_isShowing = false;
});
}