rowAt method

int rowAt(
  1. double px
)

The row nearest a pixel (on rows, the place under it: it may be past either end).

Implementation

int rowAt(double px) {
  final at = indexAt(px);
  if (!linear) return at.round();
  var best = -1;
  var off = double.infinity;
  for (var i = 0; i < count; i++) {
    final d = (pos(i) - at).abs();
    if (d < off) {
      off = d;
      best = i;
    }
  }
  return best;
}