valueToLabel method Null safety

  1. @override
int valueToLabel(
  1. Value v,
  2. Model<ProgramOperation> m

Translate value to an int that could be a label, without any range checks to see if it's a valid label. Always returns a non-negative int.


int valueToLabel(Value v, Model m) {
  final bigLabel = toBigInt(v, m).abs();
  if (bigLabel > _tooBig) {
    return 1000; // Avoid overflow
  } else {
    return bigLabel.toInt();