mutableString method
Return a cell which evaluates to a string representation of this cell's value.
The returned cell is a mutable computed cell. If the value of the returned cell is set explicitly, an integer is parsed from the assigned string value and is assigned to this cell's value.
errorValue is the value to assign to this cell when there is an
error parsing an integer from the string.
format is of type NumberFormat and is used to format the string
representation of the num value.
Note errorValue is a ValueCell's to allow the default value to be
chosen dynamically. If a constant is required use the
NumValueCellExtension.cell property e.g. 10.cell.
Pitfalls:
A binding is not established between errorValue and this cell. This
means that this cell will not react to changes in errorValue. Only
the values at the time of assigning a value to the returned cell are used.
Implementation
MutableCell<String> mutableString({
ValueCell<int> errorValue = const ValueCell.value(0),
NumberFormat? format,
}) =>
MutableComputeCell(
arguments: {this},
compute: () => format?.format(value) ?? value.toString(),
reverseCompute: (value) {
this.value = format?.tryParse(value)?.toInt() ??
int.tryParse(value) ??
errorValue.value;
});