mapRange method
Maps this value from one range fromMin, fromMax to another toMin, toMax.
Example:
double value = 50.0;
double mapped = value.mapRange(fromMin: 0.0, fromMax: 100.0, toMin: 0.0, toMax: 1.0); // 0.5
Implementation
double mapRange({
required double fromMin,
required double fromMax,
required double toMin,
required double toMax,
}) {
if (fromMax == fromMin) return toMin;
final normalized = (this - fromMin) / (fromMax - fromMin);
return toMin + normalized * (toMax - toMin);
}