RelativeRect.fromRect constructor
Creates a RelativeRect from two Rects. The second Rect provides the container, the first provides the rectangle, in the same coordinate space, that is to be converted to a RelativeRect. The output will be in the container's coordinate space.
For example, if the top left of the rect is at 0,0, and the top left of the container is at 100,100, then the top left of the output will be at -100,-100.
If the first rect is actually in the container's coordinate space, then use RelativeRect.fromSize and pass the container's size as the second argument instead.
Implementation
RelativeRect.fromRect(Rect rect, Rect container)
: left = rect.left - container.left,
top = rect.top - container.top,
right = container.right - rect.right,
bottom = container.bottom - rect.bottom;