convert method

  1. @override
void convert(
  1. T name,
  2. double? value
)
override

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

Implementation

@override
void convert(T name, double? value) {
  if (value == null) {
    for (Unit unit in _unitList) {
      unit.value = null;
      unit.stringValue = null;
    }
    return;
  }
  // Reset previous values
  for (var node in _nodeList) {
    node.value = null;
  }
  // Start the conversion
  _mapUnits[name]!.convert(value);
  for (var i = 0; i < size; i++) {
    _unitList[i].value =
        _nodeList.singleWhere((node) => node.name == _unitList[i].name).value;
    _unitList[i].stringValue = valueToString(_unitList[i].value!,
        significantFigures, removeTrailingZeros, useScientificNotation);
  }
}