xSch_TextFormField_Builder<T> method

Widget xSch_TextFormField_Builder<T>({
  1. required BuildContext context,
  2. required XCol xCol,
  3. dynamic onChanged(
    1. String
    )?,
  4. dynamic onSubmitted(
    1. String
    )?,
  5. String? hintText,
  6. List<TextInputFormatter>? inputFormatters,
  7. TextInputType? keyboardType,
  8. bool editable = true,
  9. bool label_Visible = true,
  10. bool autoFocus = false,
  11. String? value,
  12. bool? selectText,
  13. bool? multiLines,
  14. double? height,
  15. int? maxLines,
  16. Color? borderColor,
  17. Color? borderColor_Disabled,
  18. Color? labelColor_Disabled,
  19. Color? backgorundColor,
  20. Color? backgorundColor_Disabled,
  21. TextEditingController? controller,
  22. dynamic onBefore_Edit()?,
})

Implementation

Widget xSch_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,
}) {
  return XTextFormField(
    controller: value != null ? null : controller,
    border: OutlineInputBorder(borderSide: BorderSide(color: editable.not() ? (borderColor ?? Colors.grey[600]!) : (borderColor_Disabled ?? Colors.grey[700]!), width: 1)),
    disabledBorder: OutlineInputBorder(borderSide: BorderSide(color: editable.not() ? (borderColor ?? Colors.grey[600]!) : (borderColor_Disabled ?? Colors.grey[700]!), width: 1)),
    enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: editable.not() ? (borderColor ?? Colors.grey[600]!) : (borderColor_Disabled ?? Colors.grey[700]!), width: 1)),
    label: label_Visible ? (xCol.colCaption + (xCol.format == "C" ? " €" : "")) : "",
    onChanged: onChanged,
    onFieldSubmitted: (value) {
      onSubmitted == null ? null : onSubmitted(value!);
    },
    autoFocus: autoFocus,
    onTap: () {
      if (controller != null) {
        if (xCol.dataType == String) {
        } else {
          controller.selection = TextSelection(baseOffset: 0, extentOffset: controller.text.length);
        }
      }
      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.xStyleText(colorText: XSchedaState.color_Text),
    textAlign: TextAlign.left,
    labelStyle: XStyles.xStyTextForLabel(editable.not() ? (XSchedaState.color_LabelText) : (labelColor_Disabled ?? borderColor_Disabled ?? Colors.grey[700]!)), //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 ?? "inserisci.."),
    inputFormatters: inputFormatters ?? [],
  );
}