convert method

void convert(
  1. K name,
  2. V? value
)

Implementation

void convert(K name, V? value) {
  //Here we will suppose V is a double. In the case where V is a String (Numeral systems) I will override the entire function

  unitConversion.clearAllValues();
  //if the value is null also the others units are null, this is convenient to delete
  //all the other units value, for example in a unit converter app (such as Converter NOW)
  if (value == null) {
    unitConversion.clearAllValues();
    for (Unit unit in unitList) {
      unit.value = null;
      unit.stringValue = null;
    }
    return;
  }
  unitConversion.clearSelectedNode();
  unitConversion.resetConvertedNode();
  var currentUnit = unitConversion.getByName(name);
  currentUnit?.value = value as double;
  currentUnit?.selectedNode = true;
  currentUnit?.convertedNode = true;
  unitConversion.convert();
}