scale static method
Re-maps value from one range to another.
Number.scale(0.5, fromMin: 0, fromMax: 1, toMin: 0, toMax: 100); // 50
Implementation
static double scale(
num value, {
required num fromMin,
required num fromMax,
required num toMin,
required num toMax,
}) {
final fromRange = fromMax - fromMin;
if (fromRange == 0) return toMin.toDouble();
return toMin + (value - fromMin) * (toMax - toMin) / fromRange;
}