showCustomLoading method

void showCustomLoading({
  1. required Widget builder(
    1. BuildContext
    ),
  2. bool barrierDismissible = false,
  3. ComToastConfig? config,
})

显示自定义loading

Implementation

void showCustomLoading({
  required Widget Function(BuildContext) builder,
  bool barrierDismissible = false,
  ComToastConfig? config,
}) {
  final loadingConfig =
      (config ?? ComToastConfig.getDefaultConfig(ComToastType.loading))
          .copyWith(
    type: ComToastType.custom,
    builder: builder,
    clickThrough: !barrierDismissible,
  );
  loadingConfig.validate();

  _loadingCount++;
  if (_overlayManager.isLoadingShowing) return;

  _currentLoadingKey = GlobalKey<ComLoadingWidgetState>();

  final entry = OverlayEntry(
    builder: (context) => ComLoadingWidget(
      key: _currentLoadingKey!,
      message: '', // 自定义loading不使用message
      config: loadingConfig,
      barrierDismissible: barrierDismissible,
      onDismiss: barrierDismissible ? () => hideLoadingImmediately() : null,
    ),
  );

  final inserted = _overlayManager.showLoadingEntry(entry);
  if (!inserted) {
    if (_loadingCount > 0) {
      _loadingCount--;
    }
    _currentLoadingKey = null;
  }
}