BasicTextField constructor
BasicTextField({
- bool trim = false,
- String? blank,
- TextEditingController? controller,
- String? initialValue,
- InputDecoration? decoration = const InputDecoration(),
- TextInputAction? textInputAction,
- TextStyle? style,
- TextDirection? textDirection,
- TextAlign textAlign = TextAlign.start,
- bool readOnly = false,
- bool obscureText = false,
- bool autocorrect = true,
- String obscuringCharacter = '•',
- int? maxLength,
- TextInputType? keyboardType,
- ValueChanged<
String> ? onChanged, - VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onFieldSubmitted, - FormFieldSetter<
String> ? onSaved, - FormFieldValidator<
String> ? validator, - List<
TextInputFormatter> ? inputFormatters, - bool? enabled,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool enableInteractiveSelection = true,
- AutovalidateMode? autovalidateMode,
- Key? key,
Text form field that can be made required (mandatory).
trim
whether or not to trim the input data.
blank
the error message in case of blank field; if omitted, the field
will not be made required.
validator
an optional extra validation step.
Implementation
BasicTextField({
bool trim = false,
String? blank,
TextEditingController? controller,
String? initialValue,
InputDecoration? decoration = const InputDecoration(),
TextInputAction? textInputAction,
TextStyle? style,
TextDirection? textDirection,
TextAlign textAlign = TextAlign.start,
bool readOnly = false,
bool obscureText = false,
bool autocorrect = true,
String obscuringCharacter = '•',
int? maxLength,
TextInputType? keyboardType,
ValueChanged<String>? onChanged,
VoidCallback? onEditingComplete,
ValueChanged<String>? onFieldSubmitted,
FormFieldSetter<String>? onSaved,
FormFieldValidator<String>? validator,
List<TextInputFormatter>? inputFormatters,
bool? enabled,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
bool enableInteractiveSelection = true,
AutovalidateMode? autovalidateMode,
Key? key,
}) : _toBasicField = ((context) {
ValStr val = validator ?? _ok;
if (blank != null) {
val = Pair.str2(Req(blank: blank), val);
}
if (trim) {
val = Trim(val);
}
final ValueChanged<String>? maybeTrimOnChanged = onChanged == null
? null
: trim
? (String v) => onChanged(v.trim())
: onChanged;
final ValueChanged<String>? maybeTrimOnFieldSub =
onFieldSubmitted == null
? null
: trim
? (String v) => onFieldSubmitted(v.trim())
: onFieldSubmitted;
final FormFieldSetter<String>? maybeTrimOnSaved = onSaved == null
? null
: trim
? (String? v) => onSaved(v?.trim())
: onSaved;
return TextFormField(
validator: val,
keyboardType: keyboardType,
controller: controller,
initialValue: initialValue,
decoration: decoration,
textInputAction: textInputAction,
style: style,
textDirection: textDirection,
textAlign: textAlign,
readOnly: readOnly,
obscuringCharacter: obscuringCharacter,
obscureText: obscureText,
autocorrect: autocorrect,
maxLength: maxLength,
onChanged: maybeTrimOnChanged,
onEditingComplete: onEditingComplete,
onFieldSubmitted: maybeTrimOnFieldSub,
onSaved: maybeTrimOnSaved,
inputFormatters: inputFormatters,
enabled: enabled,
scrollPadding: scrollPadding,
enableInteractiveSelection: enableInteractiveSelection,
autovalidateMode: autovalidateMode,
);
}),
super(key: key);