Bounds class

A class representing the bounds (dimensions) of a chart or element.

Bounds encapsulates position and size information, providing convenient methods for working with chart dimensions.

Available extensions

Constructors

Bounds({double x = 0, double y = 0, required double width, required double height})
Creates a Bounds with position and size.
const
Bounds.fromCenter({required double centerX, required double centerY, required double width, required double height})
Creates a Bounds from center and size.
factory
Bounds.fromLTRB(double left, double top, double right, double bottom)
Creates a Bounds from left, top, right, bottom values.
factory
Bounds.fromRect(Rect rect)
Creates a Bounds from a Rect.
factory
Bounds.fromSize(Size size)
Creates a Bounds from a Size at the origin.
factory

Properties

area double
The area of the bounds.
no setter
bottom double
The bottom edge.
no setter
bottomLeft Offset
The bottom-left corner.
no setter
bottomRight Offset
The bottom-right corner.
no setter
center Offset
The center as an Offset.
no setter
centerX double
The center x coordinate.
no setter
centerY double
The center y coordinate.
no setter
hashCode int
The hash code for this object.
no setteroverride
height double
The height.
final
isEmpty bool
Whether the bounds are empty.
no setter
isNotEmpty bool
Whether the bounds are not empty.
no setter
left double
The left edge.
no setter
The right edge.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size Size
The size of the bounds.
no setter
top double
The top edge.
no setter
topLeft Offset
The top-left corner.
no setter
topRight Offset
The top-right corner.
no setter
width double
The width.
final
x double
The x position.
final
y double
The y position.
final

Methods

applyMargin(Margin margin) Bounds

Available on Bounds, provided by the MarginBoundsExtensions extension

Applies a margin to this bounds, returning the inner bounds.
contains(Offset point) bool
Whether the bounds contain a point.
containsBounds(Bounds other) bool
Whether the bounds contain another bounds.
contract(double delta) Bounds
Contracts the bounds by a delta.
copyWith({double? x, double? y, double? width, double? height}) Bounds
Creates a copy with updated values.
expand(double delta) Bounds
Expands the bounds by a delta.
expandByMargin(Margin margin) Bounds

Available on Bounds, provided by the MarginBoundsExtensions extension

Expands this bounds by a margin.
expandSides({double left = 0, double top = 0, double right = 0, double bottom = 0}) Bounds
Expands the bounds by different amounts on each side.
intersection(Bounds other) Bounds?
Returns the intersection with another bounds.
intersects(Bounds other) bool
Whether the bounds intersect another bounds.
lerp(Bounds other, double t) Bounds
Interpolates between this and another bounds.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scale(double factor) Bounds
Scales the bounds by a factor.
scaleFromCenter(double factor) Bounds
Scales the bounds around a center point.
toRect() Rect
Converts to a Rect.
toString() String
A string representation of this object.
override
translate(double dx, double dy) Bounds
Translates the bounds by an offset.
translateOffset(Offset offset) Bounds
Translates the bounds by an Offset.
union(Bounds other) Bounds
Returns the union with another bounds.

Operators

operator ==(Object other) bool
The equality operator.
override

Constants

empty → const Bounds
Empty bounds.