show method

void show({
  1. ModLoadingConfig? config,
})

Implementation

void show({ModLoadingConfig? config}) {
  config ??= ModLoadingConfig();

  _overlayEntry = OverlayEntry(
    builder: (context) => Material(
      type: MaterialType.transparency,
      child: _ModLoadingWidget(
        config: config!,
        onDismiss: config.barrierDismissible ? close : null,
      ),
    ),
  );

  _entries[_id] = _overlayEntry!;

  WidgetsBinding.instance.addPostFrameCallback((_) {
    if (Get.isOverlaysOpen) return;

    try {
      final context = Get.overlayContext;
      if (context != null) {
        Navigator.of(context).overlay?.insert(_overlayEntry!);
      } else {
        Get.printError(info: 'ModLoading: No overlay context found');
      }
    } catch (e) {
      Get.printError(info: 'ModLoading: Error showing loading - $e');
    }
  });
}