confirm method

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

Confirm something.

Implementation

Future<void> confirm({
  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 context) => AlertDialog(
        title: Text(title),
        content: Focus(
          autofocus: true,
          child: Text(message),
        ),
        actions: [
          ElevatedButton(
            onPressed: yesCallback ?? () => Navigator.pop(context),
            child: Text(yesLabel),
          ),
          ElevatedButton(
            onPressed: noCallback ?? () => Navigator.pop(context),
            child: Text(noLabel),
          ),
        ],
      ),
    );