area property
override
The total surface area of the shape.
Implementation
@override
double get area {
// Mathematically beautiful Shoelace formula for polygon area.
double sum = 0.0;
final n = vertices.length;
for (int i = 0; i < n; i++) {
final j = (i + 1) % n;
sum += (vertices[i].x * vertices[j].y) - (vertices[j].x * vertices[i].y);
}
return (sum / 2.0).abs();
}