RectExt extension

Rect transformations in this package pivot on the center unless the method name says otherwise. That's the natural choice for animation / gesture math (the center is the point that stays put during scaling), in contrast to Flutter's layout-flavored topLeft convention on Rect.fromLTRB / Rect.fromLTWH.

on

Properties

area double

Available on Rect, provided by the RectExt extension

no setter
aspectRatio double

Available on Rect, provided by the RectExt extension

no setter

Methods

baseHeight(double aspectRatio) double

Available on Rect, provided by the RectExt extension

baseRect(double aspectRatio) Rect

Available on Rect, provided by the RectExt extension

baseWidth(double aspectRatio) double

Available on Rect, provided by the RectExt extension

copyWithCenter(Offset offset) Rect

Available on Rect, provided by the RectExt extension

Same size, new center.
cropBoundaries(Rect boundaries, {double? minAspectRatio, double? maxAspectRatio}) Rect

Available on Rect, provided by the RectExt extension

Clamps this (a crop rect) to stay inside boundaries, optionally honoring an aspect-ratio range. When a part of the rect spills past an edge, it's pushed back; if the resulting aspect violates minAspectRatio / maxAspectRatio, it's resized on its center to snap back into the allowed range.
fitCoverRect(Rect baseRect, Offset touchGlobalPosition, {double pullFactor = 0.4}) Rect

Available on Rect, provided by the RectExt extension

Computes the fit-cover end rect for a double-tap on a displayed (at-base) view. Scales the rect from BoxFit.contain to BoxFit.cover (so it fills the display), then pans toward touchGlobalPosition on the overflowing axis (clamped to cover bounds).
getLimitedCenterXInside(Rect container) double

Available on Rect, provided by the RectExt extension

getLimitedCenterYInside(Rect container) double

Available on Rect, provided by the RectExt extension

getLimitedRect({required Rect container, required Offset focalPointDelta, required Offset friction}) Rect

Available on Rect, provided by the RectExt extension

Applies per-axis friction damping when the rect's edges cross the container in the direction of focalPointDelta.
isXFitInside(Rect container) bool

Available on Rect, provided by the RectExt extension

isYFitInside(Rect container) bool

Available on Rect, provided by the RectExt extension

moveCorner({required Offset delta, required Corner corner, required Size shortest, required Size? longest, required double? largest, required Rect boundaries, required double? aspectRatio}) Rect

Available on Rect, provided by the RectExt extension

moveSide({required double delta, required Side side, required Size shortest, required Size? longest, required double? largest, required Rect boundaries, required double? aspectRatio}) Rect

Available on Rect, provided by the RectExt extension

resize(double width, double height) Rect

Available on Rect, provided by the RectExt extension

Same center, new size. Aspect may change.
scale(double scale) Rect

Available on Rect, provided by the RectExt extension

Multiply both dimensions by scale; aspect preserved, center fixed.
scaleToHeight(double height) Rect

Available on Rect, provided by the RectExt extension

Scale so the new height equals height; aspect preserved, center fixed.
scaleToWidth(double width) Rect

Available on Rect, provided by the RectExt extension

Scale so the new width equals width; aspect preserved, center fixed.
shiftXToFitInside(Rect container, {double force = 1}) Rect

Available on Rect, provided by the RectExt extension

force0, 1: how much to pull the rect back inside container. 0 = no movement, 1 = fully inside.
shiftYToFitInside(Rect container, {double force = 1}) Rect

Available on Rect, provided by the RectExt extension

viewportEndRect(Rect baseRect, Rect displayRect, {double? maxScale}) Rect

Available on Rect, provided by the RectExt extension

Computes the "viewport-correct" end rect for a release-while-displayed. Mirrors the imagineai interactionEndRect: