showCustomLoading method
void
showCustomLoading({
- required Widget builder(),
- bool barrierDismissible = false,
- 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;
}
}