convert method

  1. @override
void convert(
  1. NUMERAL_SYSTEMS name,
  2. String? value
)
override

Converts a unit with a specific name (e.g. NUMERAL_SYSTEMS.decimal) and value to all other units

Implementation

@override
void convert(NUMERAL_SYSTEMS name, String? value) {
  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?.stringValue = value;
  currentUnit?.selectedNode = true;
  currentUnit?.convertedNode = true;
  unitConversion.convert();
  for (var i = 0; i < NUMERAL_SYSTEMS.values.length; i++) {
    unitList[i].stringValue = unitConversion.getByName(NUMERAL_SYSTEMS.values.elementAt(i))?.stringValue;
  }
}