isClockwiseDirection static method

bool isClockwiseDirection(
  1. List<Offset> points
)

Determine if lasso was drawn clockwise (select) or counter-clockwise (exclude)

Implementation

static bool isClockwiseDirection(List<Offset> points) {
  if (points.length < 3) return true;
  double sum = 0;
  for (int i = 0; i < points.length; i++) {
    final p1 = points[i];
    final p2 = points[(i + 1) % points.length];
    sum += (p2.dx - p1.dx) * (p2.dy + p1.dy);
  }
  return sum > 0;
}