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
Methods
-
baseHeight(
double aspectRatio) → double -
baseRect(
double aspectRatio) → Rect -
baseWidth(
double aspectRatio) → double -
copyWithCenter(
Offset offset) → Rect - Same size, new center.
-
cropBoundaries(
Rect boundaries, {double? minAspectRatio, double? maxAspectRatio}) → Rect -
Available on Rect, provided by the RectExt extension
Clampsthis(a crop rect) to stay insideboundaries, optionally honoring an aspect-ratio range. When a part of the rect spills past an edge, it's pushed back; if the resulting aspect violatesminAspectRatio/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 towardtouchGlobalPositionon the overflowing axis (clamped to cover bounds). -
getLimitedCenterXInside(
Rect container) → double -
getLimitedCenterYInside(
Rect container) → double -
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 offocalPointDelta. -
isXFitInside(
Rect container) → bool -
isYFitInside(
Rect container) → bool -
moveCorner(
{required Offset delta, required Corner corner, required Size shortest, required Size? longest, required double? largest, required Rect boundaries, required double? aspectRatio}) → Rect -
moveSide(
{required double delta, required Side side, required Size shortest, required Size? longest, required double? largest, required Rect boundaries, required double? aspectRatio}) → Rect -
resize(
double width, double height) → Rect - Same center, new size. Aspect may change.
-
scale(
double scale) → Rect -
Available on Rect, provided by the RectExt extension
Multiply both dimensions byscale; aspect preserved, center fixed. -
scaleToHeight(
double height) → Rect -
Available on Rect, provided by the RectExt extension
Scale so the new height equalsheight; aspect preserved, center fixed. -
scaleToWidth(
double width) → Rect -
Available on Rect, provided by the RectExt extension
Scale so the new width equalswidth; aspect preserved, center fixed. -
shiftXToFitInside(
Rect container, {double force = 1}) → Rect -
Available on Rect, provided by the RectExt extension
force∈0, 1: how much to pull the rect back insidecontainer. 0 = no movement, 1 = fully inside. -
shiftYToFitInside(
Rect container, {double force = 1}) → Rect -
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 imagineaiinteractionEndRect: