Closed danielithomas closed 4 months ago
Hi, prior to the v4 breaking change I could do something like this to check and get a value from a cell:
String safeGetStringFromDataItem(Data? item) { String returnVal = ""; if (item != null) { if (item.value != null) { if (item.cellType == CellType.String) { returnVal = Utility.safeGetStringValue(item.value.toString()); } } } return returnVal; }
Since v4 "cellType" has gone away. I tried a modified version of the case statement (in the readme):
// printing cell-type print('CellType: ' + switch(cell.value) { null => 'empty cell', TextCellValue() => 'text', FormulaCellValue() => 'formula', IntCellValue() => 'int', BoolCellValue() => 'bool', DoubleCellValue() => 'double', DateCellValue() => 'date', TimeCellValue => 'time', DateTimeCellValue => 'date with time', });
But things are just not working for me. Fully accepting that the problem is going to be PEBKAC, but struggling to figure this one out. Any help in understanding and managing cellTypes more effectively would be greatly appreciated.
... Aaand I'll answer my own question:
Check cell.value.runtimeType
cell.value.runtimeType
Hi, prior to the v4 breaking change I could do something like this to check and get a value from a cell:
Since v4 "cellType" has gone away. I tried a modified version of the case statement (in the readme):
But things are just not working for me. Fully accepting that the problem is going to be PEBKAC, but struggling to figure this one out. Any help in understanding and managing cellTypes more effectively would be greatly appreciated.