quantity method
9.81 [m/s²]: the number in the coherent unit of its dimension.
Implementation
Expression quantity(ExpressionToken number, ExpressionToken unitToken) {
final Unit unit;
try {
unit = Unit.parse(unitToken.text, also: scope.units);
} on UnitFormatException catch (error) {
fail(
'"[${unitToken.text}]" is not a unit: ${error.reason}.',
where: unitToken,
);
}
return ExpressionConstant(<double>[
number.number! * unit.scale + unit.offset,
], ExpressionType.measuring(unit));
}