RelativeRect class

An immutable 2D, axis-aligned, floating-point rectangle whose coordinates are given relative to another rectangle's edges, known as the container. Since the dimensions of the rectangle are relative to those of the container, this class has no width and height members. To determine the width or height of the rectangle, convert it to a Rect using toRect() (passing the container's own Rect), and then examine that object.

The fields left, right, bottom, and top must not be null.

Annotations
  • @immutable

Constructors

RelativeRect.fromLTRB(double left, double top, double right, double bottom)
Creates a RelativeRect with the given values. [...]
const
RelativeRect.fromRect(Rect rect, Rect container)
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. [...]
factory
RelativeRect.fromSize(Rect rect, Size container)
Creates a RelativeRect from a Rect and a Size. The Rect (first argument) and the RelativeRect (the output) are in the coordinate space of the rectangle described by the Size, with 0,0 being at the top left.
factory

Properties

bottom double
Distance from the bottom side of the container to the bottom side of this rectangle. [...]
final
hashCode int
The hash code for this object. [...]
read-only, override
hasInsets bool
Returns whether any of the values are greater than zero. [...]
read-only
left double
Distance from the left side of the container to the left side of this rectangle. [...]
final
Distance from the right side of the container to the right side of this rectangle. [...]
final
top double
Distance from the top side of the container to the top side of this rectangle. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

deflate(double delta) RelativeRect
Returns a new rectangle with edges moved inwards by the given delta.
inflate(double delta) RelativeRect
Returns a new rectangle with edges moved outwards by the given delta.
intersect(RelativeRect other) RelativeRect
Returns a new rectangle that is the intersection of the given rectangle and this rectangle.
shift(Offset offset) RelativeRect
Returns a new rectangle object translated by the given offset.
toRect(Rect container) Rect
Convert this RelativeRect to a Rect, in the coordinate space of the container. [...]
toSize(Size container) Size
Convert this RelativeRect to a Size, assuming a container with the given size. [...]
toString() String
Returns a string representation of this object.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
override

Static Methods

lerp(RelativeRect a, RelativeRect b, double t) RelativeRect
Linearly interpolate between two RelativeRects. [...]

Constants

fill → const RelativeRect
A rect that covers the entire container.
const RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0)