input function
HTMLInputElement
input({})
A text/password/url/number input. Returns the element so callers can read
.value.
Implementation
web.HTMLInputElement input({
required String id,
String type = 'text',
String? value,
String? placeholder,
String? autocomplete,
String? autocapitalize,
void Function()? onEnter,
}) {
final e = el('input', id: id) as web.HTMLInputElement;
e.type = type;
if (value != null) e.value = value;
if (placeholder != null) e.placeholder = placeholder;
if (autocomplete != null) e.autocomplete = autocomplete;
// Opt out of mobile auto-capitalization / -correction for case-sensitive
// identifiers (host, principal) so the keyboard doesn't capitalize the first
// letter or "correct" the value.
if (autocapitalize != null) {
e.autocapitalize = autocapitalize;
e.setAttribute('autocorrect', 'off');
e.spellcheck = false;
}
if (onEnter != null) {
e.addEventListener(
'keydown',
(web.Event ev) {
if ((ev as web.KeyboardEvent).key == 'Enter') onEnter();
}.toJS,
);
}
return e;
}