onTap property

FutureOr Function(T? value)? onTap
final

Callback that is invoked when the field is tapped.

This callback receives the current value as a parameter, allowing you to access the field's value when handling the tap event. Typically used to show a picker or dialog to modify the value.

Example:

onTap: (currentValue) async {
  final result = await showDialog(
    context: context,
    builder: (_) => SelectionDialog(initialValue: currentValue),
  );
  if (result != null) {
    controller.value = result;
  }
}

The handler may be synchronous or asynchronous (it is FutureOr<void>). AnyField ignores the return value of this callback; update the controller from inside the handler to change the field value.

Implementation

final FutureOr Function(T? value)? onTap;