showProgress static method

Future<void> showProgress(
  1. double value, {
  2. String? status,
  3. EasyLoadingMaskType? maskType,
})

show progress with value status maskType, value should be 0.0 ~ 1.0.

Implementation

static Future<void> showProgress(
  double value, {
  String? status,
  EasyLoadingMaskType? maskType,
}) async {
  assert(
    value >= 0.0 && value <= 1.0,
    'progress value should be 0.0 ~ 1.0',
  );

  if (_instance.loadingStyle == EasyLoadingStyle.custom) {
    assert(
      _instance.progressColor != null,
      'while loading style is custom, progressColor should not be null',
    );
  }

  if (_instance.w == null || _instance.progressKey == null) {
    if (_instance.key != null) await dismiss(animation: false);
    GlobalKey<EasyLoadingProgressState> _progressKey =
        GlobalKey<EasyLoadingProgressState>();
    Widget w = EasyLoadingProgress(
      key: _progressKey,
      value: value,
    );
    _instance._show(
      status: status,
      maskType: maskType,
      dismissOnTap: false,
      w: w,
    );
    _instance._progressKey = _progressKey;
  }
  // update progress
  _instance.progressKey?.currentState?.updateProgress(min(1.0, value));
  // update status
  if (status != null) _instance.key?.currentState?.updateStatus(status);
}