visible method

(int, int) visible(
  1. int count,
  2. double width
)

The first and last rows at least partly in view; (0, -1) for none.

Implementation

(int, int) visible(int count, double width) {
  if (count == 0 || width <= 0) return (0, -1);
  final first = math.max(0, (from(count, width) - 0.5).floor() + 1);
  final last = math.min(count - 1, (to(count) + 0.5).ceil() - 1);
  return (first, last);
}