confirmTask<T> method

Future<T?> confirmTask<T>({
  1. dynamic confirmTaskMessage,
  2. dynamic title,
  3. dynamic yesButton,
  4. dynamic noButton,
  5. bool canPop = false,
  6. void onPopInvoked(
    1. bool,
    2. dynamic
    )?,
  7. required Future<T?> task(),
  8. dynamic cancelTaskButton,
  9. dynamic loadingText,
  10. dynamic cancelConfirmationText,
  11. void onError(
    1. Object?
    )?,
  12. void onCancel()?,
})

Displays a confirmation dialog and shows a loader if the user confirms.

The confirmTaskMessage parameter represents the content of the confirmation dialog. The title parameter represents the title of the confirmation dialog. The yesButton parameter represents the text for the OK button in the confirmation dialog. The noButton parameter represents the text for the Cancel button in the confirmation dialog. The canPop parameter determines whether the dialog can be dismissed by popping the route. The onPopInvoked parameter is a callback function that is invoked when the dialog is popped. The task parameter is a function that returns a future representing the task to be performed. The cancelTaskButton parameter represents the text for the Cancel button in the loader. The loadingText parameter represents the text to be displayed while the task is loading. The cancelConfirmationText parameter represents the message to be displayed in the confirmation dialog.

Returns the result of the task if the user confirms, otherwise returns null.

Implementation

Future<T?> confirmTask<T>({
  dynamic confirmTaskMessage,
  dynamic title,
  dynamic yesButton,
  dynamic noButton,
  bool canPop = false,
  void Function(bool, dynamic)? onPopInvoked,
  required Future<T?> Function() task,
  dynamic cancelTaskButton,
  dynamic loadingText,
  dynamic cancelConfirmationText,
  void Function(Object?)? onError,
  void Function()? onCancel,
}) async =>
    await confirm(
      confirmTaskMessage,
      title: title,
      textOK: yesButton,
      textCancel: noButton,
      canPop: canPop,
      onPopInvoked: onPopInvoked,
    )
        ? await showTaskLoader(
            task: task,
            cancelTaskButton: cancelTaskButton,
            loadingText: loadingText,
            yesButton: yesButton,
            noButton: noButton,
            cancelConfirmationText: cancelConfirmationText,
            onError: onError,
            onCancel: onCancel,
          )
        : null;