xDialog_CellBuilder method

Container xDialog_CellBuilder(
  1. XCol xCol,
  2. BuildContext context,
  3. void setState(
    1. void ()
    ),
  4. TextEditingController controller, {
  5. TextInputType? keyboardType,
  6. bool autoFocus = true,
  7. bool label_Visible = false,
  8. List<TextInputFormatter>? inputFormatters,
})

Implementation

Container xDialog_CellBuilder(XCol xCol, BuildContext context, void Function(void Function()) setState, TextEditingController controller, {TextInputType? keyboardType, bool autoFocus = true, bool label_Visible = false, List<TextInputFormatter>? inputFormatters}) {
  Widget _widgetForCell = Container();
  //WIDGET NEL CASO FOSSE UNA STRING
  if (xCol.dataType == String && xCol.colKey.startsWith("li").not()) {
    _widgetForCell = xSch_TextFormField_Builder(
      height: null,
      context: context,
      xCol: xCol,
      autoFocus: autoFocus,
      controller: controller,
      label_Visible: label_Visible,
      multiLines: xCol.multilines,
      maxLines: xCol.multilines ? 4 : 1,
      inputFormatters: inputFormatters,
      editable: xCol.readOnly,
      keyboardType: keyboardType,
      borderColor: widget.cell_borderColor,
      borderColor_Disabled: widget.cell_borderColor_Disabled,
      labelColor_Disabled: widget.cell_labelColor_Disabled,
      onBefore_Edit: () {
        // xOnBefore_Edit(xCol, item);
      },
      // value: item ?? "",
      onChanged: (value) {
        xOnXCell_Edit_OnChanged(xCol, value);
      },
    );
  }
  //WIDGET NEL CASO FOSSE UN DATETIME
  else if (xCol.dataType == DateTime) {
    var t = controller.text.split("-");
    var dt = DateTime.parse(t[0].split(" ")[0] + "-" + t[1] + "-" + t[2]);
    _widgetForCell = xSch_DateFormField_Builder(
        xCol: xCol,
        onBefore_Edit: () {},
        // controller: controller,
        value: dt == DateTime(1900, 01, 01) ? null : dt,
        onDateSelected: (value) {
          // setState(() {
          //   btnUpdateChangesShow = true;
          xOnXCell_Edit_SubmitValue(xCol, value, setState);
          //});
        });
  }
  //WIDGET NEL CASO FOSSE UN DOUBLE
  else if (xCol.dataType == double) {
    _widgetForCell = xSch_TextFormField_Builder(
        context: context,
        selectText: true,
        editable: xCol.readOnly,
        xCol: xCol,
        label_Visible: label_Visible,
        maxLines: 1,
        borderColor: widget.cell_borderColor,
        borderColor_Disabled: widget.cell_borderColor_Disabled,
        labelColor_Disabled: widget.cell_labelColor_Disabled,
        autoFocus: true,
        onBefore_Edit: () {
          // xOnBefore_Edit(xCol, item);
        },
        keyboardType: TextInputType.number,
        controller: controller,
        // value: controller.text == "0.0" ? "" : double.parse(controller.text).toString(),
        inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /,\\\\]"))],
        onSubmitted: (value) {
          xOnXCell_Edit_SubmitValue(xCol, double.parse(value), setState);
        },
        onChanged: (value) {
          if (value != "") {
            xOnXCell_Edit_OnChanged(xCol, double.parse(value));
          } else {
            xOnXCell_Edit_OnChanged(xCol, 0.0);
          }
        });
  }
  //WIDGET NEL CASO FOSSE UN INTERO
  else if (xCol.dataType == int) {
    _widgetForCell = xSch_TextFormField_Builder(
      context: context,
      editable: xCol.readOnly,
      selectText: true,
      maxLines: 1,
      label_Visible: label_Visible,
      autoFocus: true,
      xCol: xCol,
      borderColor: widget.cell_borderColor,
      borderColor_Disabled: widget.cell_borderColor_Disabled,
      labelColor_Disabled: widget.cell_labelColor_Disabled,
      keyboardType: TextInputType.number,
      onBefore_Edit: () {
        // xOnBefore_Edit(xCol, item);
      },
      onSubmitted: (value) {
        xOnXCell_Edit_SubmitValue(xCol, value, setState);
      },
      controller: controller,
      // value: controller.text == "0.0" ? "" : controller.text,
      inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /,\\\\]"))],
      onChanged: (value) {
        if (value != "") {
          xOnXCell_Edit_OnChanged(xCol, int.parse(value));
        } else {
          xOnXCell_Edit_OnChanged(xCol, 0);
        }
      },
    );
  } else {
    return Container(width: 0, height: 0);
  }

  return Container(
    child: StatefulBuilder(builder: (context, setState) {
      return _widgetForCell;
    }),
  );
  //}
}