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,
}) {
  if (_overlayManager.isLoadingShowing) return;

  final loadingConfig =
      (config ?? ComToastConfig.getDefaultConfig(ComToastType.loading))
          .copyWith(
    type: ComToastType.custom,
    builder: builder,
    clickThrough: !barrierDismissible,
  );

  _currentLoadingKey = GlobalKey<ComLoadingWidgetState>();

  final entry = OverlayEntry(
    builder: (context) => ComLoadingWidget(
      key: _currentLoadingKey!,
      message: '', // 自定义loading不使用message
      config: loadingConfig,
      barrierDismissible: barrierDismissible,
      onDismiss: barrierDismissible ? () => hideLoading() : null,
      isCustom: true, // 标记为自定义类型
    ),
  );

  _overlayManager.showLoadingEntry(entry);
}