showConfirmMessage method

Future<void> showConfirmMessage({
  1. String title = 'Confirm',
  2. String message = 'Are you sure?',
  3. VoidCallback? yesCallback,
  4. VoidCallback? noCallback,
  5. String yesLabel = 'Yes',
  6. String noLabel = 'No',
})

Show a confirm message.

Implementation

Future<void> showConfirmMessage({
  String title = 'Confirm',
  String message = 'Are you sure?',
  VoidCallback? yesCallback,
  VoidCallback? noCallback,
  String yesLabel = 'Yes',
  String noLabel = 'No',
}) => showDialog<void>(
  context: this,
  builder: (innerContext) => AlertDialog(
    title: Text(title),
    content: Focus(autofocus: true, child: Text(message)),
    actions: [
      ElevatedButton(
        onPressed: () {
          innerContext.pop();
          yesCallback?.call();
        },
        child: Text(yesLabel),
      ),
      ElevatedButton(
        onPressed: () {
          innerContext.pop();
          noCallback?.call();
        },
        child: Text(noLabel),
      ),
    ],
  ),
);