confirmation<T> method
Future<T?>
confirmation<T>({
- required String title,
- String? description,
- Widget? content,
- bool dismissible = true,
- VoidCallback? cancel,
- VoidCallback? confirm,
- T close()?,
- String confirmText = 'Confirmar',
- String cancelText = 'Cancelar',
- bool closeOnConfirm = true,
- bool closeOnCancel = true,
- bool showCloseButton = true,
- BoxConstraints? constraints,
override
Implementation
@override
Future<T?> confirmation<T>({
required String title,
String? description,
Widget? content,
bool dismissible = true,
VoidCallback? cancel,
VoidCallback? confirm,
T Function()? close,
String confirmText = 'Confirmar',
String cancelText = 'Cancelar',
bool closeOnConfirm = true,
bool closeOnCancel = true,
bool showCloseButton = true,
BoxConstraints? constraints,
}) {
if ((description == null && content == null) || (description != null && content != null)) {
throw AssertionError('Informe um description ou content.');
}
return show(
title: title,
content: content ??
Text(
description!,
style: GoogleFonts.roboto(color: Colors.grey.shade600),
),
constraints: constraints,
showCloseButton: showCloseButton,
dismissible: dismissible,
actions: [
VvsButton.text(
cancelText,
onPressed: () {
if (cancel != null) {
cancel.call();
}
if (closeOnCancel && close != null) {
Navigator.pop(navigatorKey.currentState!.overlay!.context);
}
if (close != null) {
close.call();
}
},
),
VvsButton(
confirmText,
onPressed: () {
if (confirm != null) {
confirm.call();
}
if (closeOnConfirm && close != null) {
Navigator.pop(navigatorKey.currentState!.overlay!.context);
}
if (close != null) {
close.call();
}
},
),
],
);
}