BeforeDeleteCallback<T> typedef

BeforeDeleteCallback<T> = Future<bool> Function(T item)

Async callback that can veto a deletion operation.

Return true to allow the deletion, false to prevent it. This is useful for showing confirmation dialogs before destructive operations.

Example:

onBeforeDelete: (node) async {
  return await showDialog<bool>(
    context: context,
    builder: (context) => AlertDialog(
      title: Text('Delete Node?'),
      content: Text('Are you sure you want to delete "${node.id}"?'),
      actions: [
        TextButton(
          onPressed: () => Navigator.of(context).pop(false),
          child: Text('Cancel'),
        ),
        TextButton(
          onPressed: () => Navigator.of(context).pop(true),
          child: Text('Delete'),
        ),
      ],
    ),
  ) ?? false;
}

Implementation

typedef BeforeDeleteCallback<T> = Future<bool> Function(T item);