build method
Implementation
@override
Widget build(BuildContext context) {
TextStyle effectiveStyle =
style ?? Theme.of(context).textTheme.titleMedium!;
if (!enabled || readOnly) {
effectiveStyle = effectiveStyle.copyWith(
color: Theme.of(context).disabledColor,
);
}
InputDecoration effectiveDecoration = (decoration ??
InputDecoration(
prefix: prefix,
prefixIcon: prefixIcon,
suffix: suffix,
suffixIcon: suffixIcon,
label: labelWidget,
labelText: (labelPrefix?.isEmpty ?? true)
? label
: '$labelPrefix - $label',
border: const OutlineInputBorder(),
counterText: counterText,
enabled: enabled,
filled: filled,
fillColor: fillColor,
hintText: hintText,
contentPadding: contentPadding,
))
.applyDefaults(Theme.of(context).inputDecorationTheme);
return Padding(
padding: padding,
child: TextFormField(
controller: controller,
keyboardType: keyboard,
decoration: effectiveDecoration,
validator: enabled && validator != null
? (String? value) => validator!(value ?? '')
: null,
minLines: minLines,
maxLines: maxLines,
obscureText: obscureText,
inputFormatters: inputFormatter,
textAlign: textAlign,
maxLength: maxLength,
onSaved: enabled && onSaved != null ? _internalSave : null,
initialValue: initialValue,
enabled: enabled,
autovalidateMode: autoValidateMode,
onChanged: onChanged,
focusNode: focusNode,
textInputAction: textInputAction,
onFieldSubmitted: onFieldSubmitted,
autocorrect: autocorrect,
enableSuggestions: enableSuggestions,
textCapitalization: textCapitalization,
scrollPadding: scrollPadding,
enableInteractiveSelection: enableInteractiveSelection,
autofillHints: readOnly ? null : autofillHints,
readOnly: readOnly,
onTap: onTap,
style: effectiveStyle,
),
);
}