confirm method
Future<void>
confirm({
- String title = 'Confirm',
- String message = 'Are you sure?',
- VoidCallback? yesCallback,
- VoidCallback? noCallback,
- String yesLabel = 'Yes',
- 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),
),
],
),
);