loading<T> static method

Future<T?> loading<T>(
  1. BuildContext context, {
  2. String? message,
  3. Widget? indicator,
  4. bool useRootNavigator = true,
  5. XLook look = XLook.standard,
})

Shows a non-dismissible loading dialog.

Close it with Navigator.of(context, rootNavigator: useRootNavigator) .pop() after the operation completes.

Implementation

static Future<T?> loading<T>(
  BuildContext context, {
  String? message,
  Widget? indicator,
  bool useRootNavigator = true,
  XLook look = XLook.standard,
}) {
  final lookPreset = XDialogLook.resolve(look);
  return show<T>(
    context,
    barrierDismissible: false,
    useRootNavigator: useRootNavigator,
    builder: (_) => PopScope(
      canPop: false,
      child: AlertDialog(
        backgroundColor: lookPreset.backgroundColor,
        elevation: lookPreset.elevation,
        shape: look == XLook.standard ? null : lookPreset.shape,
        content: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            indicator ?? const CircularProgressIndicator(),
            if (message != null) ...[
              const SizedBox(width: 16),
              Flexible(child: Text(message)),
            ],
          ],
        ),
      ),
    ),
  );
}