loading<T> static method

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

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,
}) {
  return show<T>(
    context,
    barrierDismissible: false,
    useRootNavigator: useRootNavigator,
    builder: (_) => PopScope(
      canPop: false,
      child: AlertDialog(
        content: Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            indicator ?? const CircularProgressIndicator(),
            if (message != null) ...[
              const SizedBox(width: 16),
              Flexible(child: Text(message)),
            ],
          ],
        ),
      ),
    ),
  );
}