showProgress method

dynamic showProgress(
  1. BuildContext context, {
  2. String? text,
  3. JJLoadingType loadingType = JJLoadingType.circularLoading,
  4. JJProgressType progressType = JJProgressType.circularProgress,
  5. Color color = Colors.white,
  6. Color backgroundColor = Colors.black54,
  7. double width = 100,
  8. double height = 100,
  9. double radius = 20,
  10. dynamic textStyle = const TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w400),
  11. Axis axis = Axis.vertical,
})

添加loading

Implementation

showProgress(BuildContext context, {
  String? text,
  JJLoadingType loadingType = JJLoadingType.circularLoading,
  JJProgressType progressType = JJProgressType.circularProgress,
  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),
  Axis axis = Axis.vertical

}) async {

  OverlayState? overlayState = Overlay.of(context);
  if (_overlayEntry == null) {
    _overlayEntry = OverlayEntry(builder: (context) {
      _loading ??= JJLoading(
        initialText: text,
        textStyle: textStyle,
        loadingType: loadingType,
        progressType: progressType,
        color: color,
        backgroundColor: backgroundColor,
        axis: axis,
        isValueListen: true,
      );
      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;
  });

}