xEditDialog_CellBuilder method
Container
xEditDialog_CellBuilder(
- XFDataItem item,
- XCol xCol,
- BuildContext context,
- void setState(
- void ()
- TextEditingController controller, {
- TextInputType? keyboardType,
- bool autoFocus = false,
- bool label_Visible = false,
- List<
TextInputFormatter> ? inputFormatters,
CellBuilder dellxEntry
Implementation
Container xEditDialog_CellBuilder(XFDataItem item, XCol xCol, BuildContext context, void Function(void Function()) setState, TextEditingController controller, {TextInputType? keyboardType, bool autoFocus = false, 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,
//value: controller != null ? null : item[xCol.colKey],
maxLines: xCol.multilines ? 4 : 1,
inputFormatters: inputFormatters,
editable: xCol.readOnly,
keyboardType: keyboardType,
borderColor: widget.xCell_borderColor,
borderColor_Disabled: widget.xCell_borderColor_Disabled,
labelColor_Disabled: widget.xCell_labelColor_Disabled,
onSubmitted: (p0) => xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, p0),
onBefore_Edit: () {
controller.selection = TextSelection(baseOffset: 0, extentOffset: controller.text.length);
},
onChanged: (value) => item[xCol.colKey] = value,
);
}
//WIDGET NEL CASO FOSSE UN DATETIME
else if (xCol.dataType == DateTime) {
_widgetForCell = xSch_DateFormField_Builder(
xCol: xCol,
onBefore_Edit: () {},
value: item[xCol.colKey],
format: xCol.format,
onDateSelected: (value) {
item[xCol.colKey] = value;
xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, value);
});
}
//WIDGET NEL CASO FOSSE UN DOUBLE
else if (xCol.dataType == double) {
_widgetForCell = xSch_TextFormField_Builder(
context: context,
selectText: true,
editable: xCol.readOnly,
//value: controller != null ? null : item[xCol.colKey].toString(),
xCol: xCol,
label_Visible: label_Visible,
maxLines: 1,
borderColor: widget.xCell_borderColor,
borderColor_Disabled: widget.xCell_borderColor_Disabled,
labelColor_Disabled: widget.xCell_labelColor_Disabled,
height: null,
autoFocus: autoFocus,
onBefore_Edit: () {
controller.selection = TextSelection(baseOffset: 0, extentOffset: controller.text.length);
},
keyboardType: TextInputType.number,
controller: controller,
inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /,\\\\]"))],
onSubmitted: (value) => xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, double.parse(value)),
onChanged: (value) {
if (value != "") {
xOnXCell_Edit_OnChanged(item, xCol, double.parse(value));
item[xCol.colKey] = double.parse(value);
} else {
xOnXCell_Edit_OnChanged(item, xCol, 0.0);
item[xCol.colKey] = 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,
// value: controller != null ? null : item[xCol.colKey].toString(),
autoFocus: autoFocus,
height: null,
xCol: xCol,
borderColor: widget.xCell_borderColor,
borderColor_Disabled: widget.xCell_borderColor_Disabled,
labelColor_Disabled: widget.xCell_labelColor_Disabled,
keyboardType: TextInputType.number,
onBefore_Edit: () {
controller.selection = TextSelection(baseOffset: 0, extentOffset: controller.text.length);
},
onSubmitted: (value) {
xOnXCell_Edit_SubmitValue_INTERNAL(item, xCol, int.parse(value));
},
controller: controller,
inputFormatters: [FilteringTextInputFormatter.deny(RegExp("[- /.,\\\\]"))],
onChanged: (value) {
if (value != "") {
xOnXCell_Edit_OnChanged(item, xCol, int.parse(value));
item[xCol.colKey] = int.parse(value);
} else {
xOnXCell_Edit_OnChanged(item, xCol, 0);
item[xCol.colKey] = 0;
}
},
);
} else {
return Container(width: 0, height: 0);
}
return Container(margin: EdgeInsets.only(top: 2), width: kIsWeb ? xCol.width : null, child: StatefulBuilder(builder: (context, setState) => _widgetForCell));
}