editArea method
TextFormField
editArea({
- required String name,
- Key? key,
- String? initialValue,
- String? label,
- String? hint,
- int? minLength,
- int maxLength = 256,
- bool allowEmpty = true,
- OnValue<
String> ? onSubmitted, - Widget? prefixIcon,
- String? helperText,
- String? errorText,
- Widget? suffixIcon,
- Color? cursorColor,
- TextValidator? validator,
- List<
TextInputFormatter> ? inputFormatters, - bool autofocus = false,
- int? minLines = 3,
- int? maxLines = 6,
- bool readonly = false,
- InputDecoration? decoration,
- InputBorder? border,
- void onChanged()?,
- void onTapOutside()?,
Implementation
TextFormField editArea({
required String name,
Key? key,
String? initialValue,
String? label,
String? hint,
int? minLength,
int maxLength = 256,
bool allowEmpty = true,
OnValue<String>? onSubmitted,
Widget? prefixIcon,
String? helperText,
String? errorText,
Widget? suffixIcon,
Color? cursorColor,
TextValidator? validator,
List<TextInputFormatter>? inputFormatters,
bool autofocus = false,
int? minLines = 3,
int? maxLines = 6,
bool readonly = false,
InputDecoration? decoration,
InputBorder? border,
void Function(String)? onChanged,
void Function(PointerDownEvent)? onTapOutside,
}) {
_nameControllerMap[name] ??= TextEditingController(text: initialValue);
_focusMap[name] ??= FocusNode();
var lv = LengthValidator(minLength: minLength ?? 0, maxLength: maxLength, allowEmpty: allowEmpty);
TextValidator tv = validator == null ? lv : ListValidator([validator, lv]);
return TextFormField(
key: key ?? UniqueKey(),
controller: _nameControllerMap[name],
maxLength: maxLength,
validator: tv,
maxLines: maxLines,
minLines: minLines,
onFieldSubmitted: onSubmitted,
onChanged: onChanged,
textAlign: TextAlign.start,
keyboardType: TextInputType.multiline,
textInputAction: TextInputAction.newline,
inputFormatters: inputFormatters,
readOnly: readonly,
autofocus: autofocus,
cursorColor: cursorColor,
focusNode: _focusMap[name],
onTapOutside: onTapOutside ?? (e) => _focusMap[name]?.unfocus(),
decoration:
decoration ??
InputDecoration(
labelText: label,
hintText: hint,
counterText: "",
prefixIcon: prefixIcon,
helperText: helperText,
errorText: errorText,
border: border ?? OutlineInputBorder(),
),
);
}