normalized method

double normalized(
  1. num fromMin,
  2. num fromMax, [
  3. num toMin = 0.0,
  4. num toMax = 1.0,
])

Normalizes this value from [fromMin, fromMax] into [toMin, toMax].

Implementation

double normalized(num fromMin, num fromMax, [num toMin = 0.0, num toMax = 1.0]) {
  final range = fromMax - fromMin;
  if (range == 0) {
    throw ArgumentError('Source range cannot be zero (fromMin == fromMax == $fromMin)');
  }
  return ((toMax - toMin) * ((this - fromMin) / range) + toMin).toDouble();
}