FractionalOffset.fromOffsetAndRect constructor

FractionalOffset.fromOffsetAndRect(
  1. Offset offset,
  2. Rect rect
)

Creates a fractional offset from a specific offset and rectangle.

The offset is assumed to be relative to the same origin as the rectangle.

If the offset is relative to the top left of the rectangle, use FractionalOffset.fromOffsetAndSize instead, passing rect.size.

The returned FractionalOffset describes the position of the Offset in the Rect, as a fraction of the Rect.

Implementation

factory FractionalOffset.fromOffsetAndRect(Offset offset, Rect rect) {
  return FractionalOffset.fromOffsetAndSize(
    offset - rect.topLeft,
    rect.size,
  );
}