showLoading method

dynamic showLoading(
  1. BuildContext context, {
  2. String? text,
  3. JJLoadingType loadingType = JJLoadingType.circularLoading,
  4. Color color = Colors.white,
  5. Color backgroundColor = Colors.black54,
  6. double width = 100,
  7. double height = 100,
  8. double radius = 20,
  9. 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;
  });

}