Rect class final
A rectangular area defined by its top-left corner (x, y)
and dimensions.
Equality
Two rectangles are equal if their x, y, width, and height are equal.
- Available Extensions
- Annotations
Constructors
- Rect.fromLTWH(int x, int y, int width, int height)
-
Creates a new rectangle.
const
- Rect.fromSize(int width, int height)
-
Creates a new rectangle of
width
andheight
with a default origin.const
Properties
- area → int
-
The area of the rectangle.
no setter
- bottom → int
-
The bottom edge of this rectangle on the y-axis.
no setter
- bottomLeft → Offset
-
The bottom-left corner of this rectangle.
no setter
- bottomRight → Offset
-
The bottom-right corner of this rectangle.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- height → int
-
Height of this rectangle.
final
- isEmpty → bool
-
Whether the rectangle is empty (has no area).
no setter
- isNotEmpty → bool
-
Whether the rectangle is not empty (has area).
no setter
- left → int
-
The left edge of this rectangle on the x-axis.
no setter
-
offsets
→ Iterable<
Offset> -
Iterable of all offsets within this rectangle.
no setter
- right → int
-
The right edge of this rectangle on the x-axis.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- top → int
-
The top edge of this rectangle on the y-axis.
no setter
- topLeft → Offset
-
The top-left corner of this rectangle.
no setter
- topRight → Offset
-
The top-right corner of this rectangle.
no setter
- width → int
-
Width of this rectangle.
final
- x → int
-
X-coordinate of the top-left corner of this rectangle.
final
- y → int
-
Y-coordinate of the top-left corner of this rectangle.
final
Methods
-
clamp(
Rect bounds) → Rect -
Clamps this rectangle to fit within the given
bounds
. -
contains(
Offset offset) → bool -
Returns whether this rectangle contains the given
offset
. -
containsRect(
Rect rect) → bool -
Returns whether this rectangle contains the given
rect
. -
copyWith(
{int? x, int? y, int? width, int? height}) → Rect - Returns a copy of this rectangle with the given arguments replaced.
-
intersect(
Rect other) → Rect -
Returns an intersection of this rectangle and
other
. -
intersects(
Rect other) → bool -
Returns whether this rectangle intersects with
other
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
union(
Rect other) → Rect -
Returns a rectangle that contains both this rectangle and
other
. -
withOffset(
Offset offset) → Rect -
Returns a rectangle with a new
offset
without modifying its size.
Operators
-
operator &(
Rect other) → Rect -
Returns a union of this rectangle and
other
. -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator |(
Rect other) → Rect -
Returns an intersection of this rectangle and
other
.