invert method

DateTime invert(
  1. double value
)

Maps a range value back to a DateTime.

Implementation

DateTime invert(double value) {
  final d0 = _domain[0].millisecondsSinceEpoch.toDouble();
  final d1 = _domain[1].millisecondsSinceEpoch.toDouble();
  final r0 = _range[0];
  final r1 = _range[1];

  double t = normalize(value, r0, r1);

  if (_clamp) {
    t = t.clamp(0.0, 1.0);
  }

  final ms = interpolateNumber(d0, d1)(t);
  return DateTime.fromMillisecondsSinceEpoch(ms.round());
}