confirmation<T> method

  1. @override
Future<T?> confirmation<T>({
  1. required String title,
  2. String? description,
  3. Widget? content,
  4. bool dismissible = true,
  5. VoidCallback? cancel,
  6. VoidCallback? confirm,
  7. T close()?,
  8. String confirmText = 'Confirmar',
  9. String cancelText = 'Cancelar',
  10. bool closeOnConfirm = true,
  11. bool closeOnCancel = true,
  12. bool showCloseButton = true,
  13. 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();
          }
        },
      ),
    ],
  );
}