events<V> function
Map<String, EventCallback>
events<V>({
- VoidCallback? onClick,
- ValueChanged<
V> ? onInput, - ValueChanged<
V> ? onChange,
Helper function to provide typed event handlers to the events property of html components.
Implementation
@optionalTypeArgs
Map<String, EventCallback> events<V>({
/// Listens to the 'click' event.
///
/// If the target element is an anchor (`<a>`) element,
/// this overrides the default behavior of the link and
/// doesn't visit the specified `href` when clicked.
VoidCallback? onClick,
/// Listens to the 'input' event.
///
/// When providing a generic type for [V], it must be according to the target element:
///
/// - `bool?` for checkbox or radio input elements
/// - `num?` for number input elements
/// - `DateTime` for date input elements
/// - `List<File>?` for file input elements
/// - `List<String>` for select elements
/// - `String` for text input and textarea elements
/// - `Null` for all other elements
ValueChanged<V>? onInput,
/// Listens to the 'change' event.
///
/// When providing a generic type for [V], it must be according to the target element:
///
/// - `bool?` for checkbox or radio input elements
/// - `num?` for number input elements
/// - `DateTime` for date input elements
/// - `List<File>?` for file input elements
/// - `List<String>` for select elements
/// - `String` for text input and textarea elements
/// - `Null` for all other elements
ValueChanged<V>? onChange,
}) => {
if (onClick != null)
'click': (event) {
if (kIsWeb && (event.target.isHtmlAnchorElement)) {
event.preventDefault();
}
onClick();
},
if (onInput != null) 'input': _callWithValue('onInput', onInput),
if (onChange != null) 'change': _callWithValue('onChange', onChange),
};