buildTextField method

TextField buildTextField(
  1. ColorScheme colors, {
  2. String? label,
  3. String? placeholder,
  4. bool autoFocus = false,
  5. bool readOnly = false,
  6. bool disabled = false,
  7. int maxLines = 1,
  8. FocusNode? focusNode,
  9. TextInputType? keyboardType,
  10. TextInputAction? textInputAction,
  11. List<TextInputFormatter>? inputFormatters,
  12. TextEditingController? controller,
  13. 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,
  );
}