snapPoint method

double snapPoint(
  1. double value,
  2. double velocity,
  3. List<double> points
)

Implementation

double snapPoint(
  double value,
  double velocity,
  List<double> points,
) {
  var point = value + 0.2 * velocity;
  var deltas = points.map((p) => (point - p).abs()).toList();
  var minDelta = deltas.reduce(min);
  return points.firstWhere((p) => (point - p).abs() == minDelta);
}