loadWithTask static method

Future<void> loadWithTask({
  1. required String task,
  2. required Future process(),
  3. ConsoleLoader? loader,
  4. ConsoleColor? loaderColor,
  5. Duration? loaderSpeed,
  6. LoaderPosition? loaderPosition,
  7. String? loaderSuccessReplacement,
  8. ConsoleLoaderBase? customLoader,
})

Supply a task and a process future for that task, and show a beautiful loader till the task is finished. You can also customize a replacement output when it's done.

Implementation

static Future<void> loadWithTask({
  required String task,
  required Future Function() process,
  //
  ConsoleLoader? loader,
  ConsoleColor? loaderColor,
  Duration? loaderSpeed,
  LoaderPosition? loaderPosition,
  String? loaderSuccessReplacement,
  //
  ConsoleLoaderBase? customLoader,
}) async =>
    await loadWithTaskImpl(
      task: task,
      process: process,
      loader: loader ?? ConsoleLoader.spinner,
      loaderColor: loaderColor ?? ConsoleColor.cyan,
      loaderSpeed: loaderSpeed ?? const Duration(milliseconds: 100),
      loaderPosition: loaderPosition ?? LoaderPosition.before,
      loaderSuccessReplacement:
          loaderSuccessReplacement ?? '✓'.withColor(ConsoleColor.green),
      customLoader: customLoader,
    );