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

  final baseConfig =
      ComToastConfig.getDefaultConfig(ComToastType.loading).copyWith(
    clickThrough: !barrierDismissible,
  );
  final loadingConfig = config != null
      ? baseConfig.copyWith(
          builder: config.builder,
          backgroundColor: config.backgroundColor,
          textColor: config.textColor,
          fontSize: config.fontSize,
          padding: config.padding,
          borderRadius: config.borderRadius,
          maxWidth: config.maxWidth,
          animationDuration: config.animationDuration,
          showShadow: config.showShadow,
          shadowColor: config.shadowColor,
          shadowOffset: config.shadowOffset,
          shadowBlurRadius: config.shadowBlurRadius,
        )
      : baseConfig;

  _currentLoadingKey = GlobalKey<ComLoadingWidgetState>();

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

  _overlayManager.showLoadingEntry(entry);
}