// Dart has a habit of using double-inclusive bounds, // and I strongly prefer half-open bounds // // So: Here's a reimplementation of the geometry I need class Size { final int dx; final int dy; Size(this.dx, this.dy) { assert(dx >= 0); assert(dy >= 0); } } class Offset { final int x; final int y; const Offset(this.x, this.y); } class Rect { final int x0; final int y0; final int dx; final int dy; int get x1 => x0 + dx; int get y1 => y0 + dy; Rect(this.x0, this.y0, this.dx, this.dy) { assert(dx >= 0); assert(dy >= 0); } bool contains(int x, int y) { return x0 <= x && x < x1 && y0 <= y && y < y1; } bool containsPoint(Offset xy) { return contains(xy.x, xy.y); } bool containsRect(Rect rect) { return x0 <= rect.x0 && y0 <= rect.y0 && rect.x1 <= x1 && rect.y1 <= y1; } }