fromLine static method

Rect fromLine(
  1. Offset a,
  2. Offset b,
  3. double width
)

Implementation

static Rect fromLine(Offset a, Offset b, double width) {
  final angle = (b - a).direction;
  final topLeft = a.translate(-width / 2 * math.cos(angle), -width / 2 * math.sin(angle));
  final bottomRight = b.translate(width / 2 * math.cos(angle), width / 2 * math.sin(angle));
  return Rect.fromPoints(topLeft, bottomRight);
}