safeNormalized method
Like normalized but returns fallback instead of throwing when
source range is zero. Useful in reactive/UI code where division by
zero is a transient state rather than a programmer error.
Implementation
double safeNormalized(num fromMin, num fromMax, {num toMin = 0.0, num toMax = 1.0, double fallback = 0.0}) {
final range = fromMax - fromMin;
if (range == 0) return fallback;
return ((toMax - toMin) * ((this - fromMin) / range) + toMin).toDouble();
}