normalize method

double normalize(
  1. double end, [
  2. double start = 0,
  3. int roundTo = 6
])

Implementation

double normalize(double end, [double start = 0, int roundTo = 6]) {
  final tuple = start.sort(end);

  start = tuple.first.toDouble();
  end = tuple.second.toDouble();
  if (this <= start) return 0;
  if (this >= end) return 1;

  final div = (this - start) / (end - start);
  return div.roundTo(roundTo);
}