showLoading method

void showLoading({
  1. String? message,
  2. bool barrierDismissible = false,
  3. ComToastConfig? config,
})

显示普通loading

Implementation

void showLoading({
  String? message,
  bool barrierDismissible = false,
  ComToastConfig? config,
}) {
  final baseConfig =
      (config ?? ComToastConfig.getDefaultConfig(ComToastType.loading))
          .copyWith(clickThrough: !barrierDismissible);
  final loadingConfig = baseConfig;
  loadingConfig.validate();

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

  _currentLoadingKey = GlobalKey<ComLoadingWidgetState>();

  final entry = OverlayEntry(
    builder: (context) => ComLoadingWidget(
      key: _currentLoadingKey!,
      message: message,
      config: loadingConfig,
      barrierDismissible: barrierDismissible,
      onDismiss: barrierDismissible ? () => hideLoadingImmediately() : null,
    ),
  );

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