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({
  final String title = 'Confirm',
  final String message = 'Are you sure?',
  final VoidCallback? yesCallback,
  final VoidCallback? noCallback,
  final String yesLabel = 'Yes',
  final String noLabel = 'No',
}) => showDialog<void>(
  context: this,
  builder: (final 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),
      ),
    ],
  ),
);