buildTextField method
TextField
buildTextField(
- ColorScheme colors, {
- String? label,
- String? placeholder,
- bool autoFocus = false,
- bool readOnly = false,
- bool disabled = false,
- int maxLines = 1,
- FocusNode? focusNode,
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- List<
TextInputFormatter> ? inputFormatters, - TextEditingController? controller,
- ValueChanged<
String> ? onValueChanged,
Implementation
TextField buildTextField(
ColorScheme colors, {
String? label,
String? placeholder,
bool autoFocus = false,
bool readOnly = false,
bool disabled = false,
int maxLines = 1,
FocusNode? focusNode,
TextInputType? keyboardType,
TextInputAction? textInputAction,
List<TextInputFormatter>? inputFormatters,
TextEditingController? controller,
ValueChanged<String>? onValueChanged,
}) {
return TextField(
controller: controller,
readOnly: readOnly,
autofocus: autoFocus,
focusNode: focusNode,
enabled: !disabled,
textCapitalization: textCapitalization,
autocorrect: autocorrect,
enableSuggestions: enableSuggestions,
maxLength: maxLength,
maxLengthEnforcement: maxLengthEnforcement,
cursorHeight: fieldFontSize + 2,
style: getTextStyle(colors, disabled),
decoration: getInputDecoration(colors, label, placeholder),
maxLines: maxLines,
scrollPhysics: const BouncingScrollPhysics(),
scrollPadding: const EdgeInsets.all(8),
obscureText: obscureText,
inputFormatters: inputFormatters ?? this.inputFormatters,
keyboardType: disabled || readOnly
? TextInputType.none
: (maxLines > 1 ? TextInputType.multiline : this.keyboardType ?? keyboardType ?? TextInputType.text),
textInputAction: this.textInputAction ?? (maxLines > 1 ? TextInputAction.newline : textInputAction ?? TextInputAction.next),
textAlignVertical: maxLines > 1 ? TextAlignVertical.top : TextAlignVertical.center,
onChanged: onValueChanged,
);
}