xLayout_TextFormField_Builder<T> method
Widget
xLayout_TextFormField_Builder<T>({
- required BuildContext context,
- required XCol xCol,
- dynamic onChanged()?,
- dynamic onSubmitted()?,
- String? hintText,
- List<
TextInputFormatter> ? inputFormatters, - TextInputType? keyboardType,
- bool editable = true,
- bool label_Visible = true,
- bool autoFocus = false,
- String? value,
- bool? selectText,
- bool? multiLines,
- double? height,
- int? maxLines,
- Color? borderColor,
- Color? borderColor_Disabled,
- Color? labelColor_Disabled,
- Color? backgorundColor,
- Color? backgorundColor_Disabled,
- TextEditingController? controller,
- dynamic onBefore_Edit()?,
- FocusNode? focusNode,
Widget TextFormField Editor Generico
Implementation
Widget xLayout_TextFormField_Builder<T>({
required BuildContext context,
required XCol xCol,
Function(String)? onChanged,
Function(String)? onSubmitted,
String? hintText,
List<TextInputFormatter>? inputFormatters,
TextInputType? keyboardType,
bool editable = true,
bool label_Visible = true,
bool autoFocus = false,
String? value,
bool? selectText,
bool? multiLines,
double? height,
int? maxLines,
Color? borderColor,
Color? borderColor_Disabled,
Color? labelColor_Disabled,
Color? backgorundColor,
Color? backgorundColor_Disabled,
TextEditingController? controller,
Function()? onBefore_Edit,
FocusNode? focusNode,
}) {
OutlineInputBorder outLineBorder = OutlineInputBorder(borderSide: BorderSide(color: editable.not() ? (xCellEditable_borderColor_Visible ? (xCol.xmodelXprop.col_Color == Colors.black ? (borderColor ?? Colors.grey[400]!) : xCol.xmodelXprop.col_Color) : borderColor ?? Colors.grey[400]!) : (borderColor_Disabled ?? Colors.grey[400]!), width: 1));
UnderlineInputBorder underLineBorder = UnderlineInputBorder(borderSide: BorderSide(color: editable.not() ? (xCellEditable_borderColor_Visible ? (xCol.xmodelXprop.col_Color == Colors.black ? (borderColor ?? Colors.grey[400]!) : xCol.xmodelXprop.col_Color) : borderColor ?? Colors.grey[400]!) : (borderColor_Disabled ?? Colors.grey[400]!), width: 1));
return XTextFormField(
controller: value != null ? null : controller,
border: widget.isEditable ? underLineBorder : outLineBorder,
disabledBorder: widget.isEditable ? underLineBorder : outLineBorder,
enabledBorder: widget.isEditable ? underLineBorder : outLineBorder,
focusedBorder: widget.isEditable ? underLineBorder : outLineBorder,
label: label_Visible ? xCol.colCaption + (editable ? "🔒" : "") : "",
onChanged: onChanged,
focusNode: focusNode,
floatingLabelBehaviorActive: widget.isEditable ? FloatingLabelBehavior.always : FloatingLabelBehavior.auto,
onEditingComplete: () => onSubmitted == null ? null : onSubmitted(value!),
onFieldSubmitted: (value) => onSubmitted == null ? null : onSubmitted(value!),
autoFocus: autoFocus,
maxLenght: xCol.maxLenght == 0 ? null : xCol.maxLenght,
onTap: () {
if (controller != null) {
if (xCol.dataType == String)
null;
else
controller.selection = TextSelection(baseOffset: 0, extentOffset: controller.text.length);
}
if (onBefore_Edit != null) {
onBefore_Edit();
}
},
initialValue: controller != null ? null : value,
// borderVisible: editable.not(),
maxLines: maxLines,
isCollapsed: false,
enabled: editable.not(),
height: null,
fillColor: editable ? Colors.transparent : XSchedaState.color_CellBackGorundDisabled,
filled: XSchedaState.color_CellBackGorundDisabled != null ? true : false,
multiLines: (xCol.colCaption.toLowerCase().contains("email") || (xCol.colKey.contains("sconti") || xCol.colKey.contains("sconto")) || xCol.colCaption.toLowerCase().contains("inidrizzo") || xCol.colCaption.toLowerCase().contains("ind"))
? false
: ((xCol.colCaption.toLowerCase().contains("cell")) || (xCol.colCaption.toLowerCase().contains("tel")))
? false
: multiLines ?? false,
contentPadding: EdgeInsets.only(top: 7, left: 5, bottom: 7),
textStyle: XStyles.xStyTextForDescr(textColor: XSchedaState.color_Text),
textAlign: xCol.dataType is int || xCol.dataType is double ? TextAlign.end : TextAlign.start,
labelStyle: XStyles.xStyTextForLabel(textColor: xCol.xmodelXprop.col_Color == Colors.black ? XColors.foregroundLight : xCol.xmodelXprop.col_Color), //XSchedaState.colorOfHintText
keyboardType: keyboardType ??
((xCol.colCaption.toLowerCase().contains("email"))
? TextInputType.emailAddress
: ((xCol.colCaption.toLowerCase().contains("cell")) || (xCol.colCaption.toLowerCase().contains("tel")))
? TextInputType.phone
: (xCol.colKey.contains("sconti") || xCol.colKey.contains("sconto"))
? TextInputType.number
: TextInputType.text),
textCapitalization: (xCol.dataType == String && xCol.colKey.startsWith("li").not()) ? TextCapitalization.sentences : TextCapitalization.none,
hintText: editable ? "..." : (hintText ?? "..."),
hintStyle: XStyles.xStyTextForSubDescr(textColor: XSchedaState.color_HintText),
inputFormatters: inputFormatters ?? [],
);
}