RelativeRect class Null safety
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.
- Annotations
Constructors
- RelativeRect.fromDirectional({required TextDirection textDirection, required double start, required double top, required double end, required double bottom})
-
Creates a RelativeRect from horizontal position using
start
andend
rather thanleft
andright
.factory - 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-onlyoverride
- 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
- right → double
-
Distance from the right side of the container to the right side of this rectangle.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- top → double
-
Distance from the top side of the container to the top side of this rectangle.
final
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.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
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 -
A string representation of this object.
override
Operators
-
operator ==(
Object 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.
RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0)