areOffsetsVisible method

bool areOffsetsVisible(
  1. Iterable<Offset> offsets, [
  2. double margin = 0
])
inherited

Determine whether the specified offsets are visible within the viewport

Always returns false if the specified list is empty.

Implementation

bool areOffsetsVisible(Iterable<Offset> offsets, [double margin = 0]) {
  if (offsets.isEmpty) {
    return false;
  }
  double minX;
  double maxX;
  double minY;
  double maxY;
  minX = maxX = offsets.first.dx;
  minY = maxY = offsets.first.dy;
  for (final Offset offset in offsets) {
    if (viewportRect.contains(offset)) return true;
    if (minX > offset.dx) minX = offset.dx;
    if (minY > offset.dy) minY = offset.dy;
    if (maxX < offset.dx) maxX = offset.dx;
    if (maxY < offset.dy) maxY = offset.dy;
  }
  return viewportRect.overlaps(Rect.fromLTRB(
    minX - margin,
    minY - margin,
    maxX + margin,
    maxY + margin,
  ));
}