physics library

Classes

SimulationCurve
Curve that exactly tracks a Simulation's position over its duration. Maps normalized animation time t ∈ [0, 1] to normalized position progress ∈ [0, 1].

Enums

DragDirectionState
Discrete direction state for a per-axis drag/release. Four-value taxonomy that mirrors FrictionConfig's slots: combines extending-vs-retracting (motion sign relative to base) with in-display-vs-past-display (rect's actual edge vs display edge).
ScaleSide
Side of the scale axis active at the given width.

Extensions

FrictionConfigByDirection on FrictionConfig
Picks the matching Friction ramp from a FrictionConfig for the given direction state. One-line mapping that mirrors the enum's shape to the config's four slots.
GestureBoundsPhysics on GestureBounds
Convenience method on GestureBounds for the friction primitive.

Functions

applyDragTransform({required Offset newCenter, required Rect baseRect, required double aspectRatio, required double scaleFactor}) Rect
Pure rect-construction helper. Takes the final per-axis newCenter (already decided by the caller's routing — scaleResponse center, anchor center, or friction-translated current center) and the final scaleFactor (multiplier on baseRect's width). Builds the new rect centered at newCenter with newWidth = baseRect.width * scaleFactor, newHeight = newWidth / aspectRatio.
axisStateScale(double signedAmount, double currentWidth, double baseWidth, ShrinkBounds? shrink, ExpandBounds? expand) ScaleAxisState
Computes the scale-axis state given the current width and motion direction.
axisStateX(double signedAmount, Rect currentRect, Rect originRect, Rect displayRect) AxisState
Computes the X-axis state given the current motion (signedAmount is the motion direction sign, e.g., delta or velocity) and the rect geometry.
axisStateY(double signedAmount, Rect currentRect, Rect originRect, Rect displayRect) AxisState
Computes the Y-axis state.
boundForX({required double delta, required Rect currentRect, required Rect baseRect}) DragBound
Which X-axis bound the rect is currently sitting on. If centered at base, delta's sign decides (positive → right).
boundForY({required double delta, required Rect currentRect, required Rect baseRect}) DragBound
Which Y-axis bound the rect is currently sitting on. If centered at base, delta's sign decides (positive → bottom).
computeDragRect({required GestureBounds bounds, required Rect currentRect, required Rect originRect, required Rect displayRect, required double aspectRatio, required Offset focalPoint, required Offset focalPointDelta, required Rect startRect, required Offset startFocalPoint, required Offset anchorFn(AnchorContext)}) Rect
New rect for a DragGesture update. Free pan (no scaleResponse) is pure friction-damped translation; scaleResponse routes through the anchor pipeline (focal-preserving size + position).
defaultDragAnchor(AnchorContext ctx) Offset
Default focal-point-preserving anchor: the rect.center is positioned so the user's finger stays at the same relative point of the rect as it scales. Used when no Overrides.anchor is configured.
directionStateForX({required double delta, required Rect currentRect, required Rect baseRect, required Rect displayRect}) DragDirectionState
Four-value X-axis direction state: combines the motion direction (extending vs retracting, decided by delta's sign relative to boundForX) with whether the rect's relevant edge is past the display edge.
directionStateForY({required double delta, required Rect currentRect, required Rect baseRect, required Rect displayRect}) DragDirectionState
Four-value Y-axis direction state — mirror of directionStateForX.
frictionFromScaleState({required ScaleAxisState state, required ShrinkBounds? shrink, required ExpandBounds? expand, required double delta}) double
Friction-scaled width delta given a scale-axis state. Absent side config = blocked (returns 0). Absent friction = free (returns delta).
frictionFromState({required AxisState state, required GestureBounds bounds, required double delta}) double
Friction-scaled delta given a per-axis state. Absent bound = blocked (returns 0). Absent friction = free (returns delta).
releaseFromStateScale({required double width, required double baseWidth, required ShrinkBounds? shrink, required ExpandBounds? expand, required double velocity}) ScaleRelease
Computes the ScaleRelease plan given gesture-end scale-axis state.
releaseFromStateX({required Rect currentRect, required Rect displayRect, required GestureBounds bounds, required double velocity, Rect? projectedRect}) HorizontalRelease
Computes the HorizontalRelease plan for the X axis given gesture-end state.
releaseFromStateY({required Rect currentRect, required Rect displayRect, required GestureBounds bounds, required double velocity, Rect? projectedRect}) VerticalRelease
Computes the VerticalRelease plan for the Y axis given gesture-end state.
resolveDragArena({required Offset totalDelta, required Map<DragStart, DragGesture> registered, double minDistance = 10}) ActiveGesture?
Resolves a drag gesture from the registered map for the accumulated motion vector. Returns the matching ActiveGesture, or null if no axis has crossed minDistance yet, or no registered key matches.
resolveScaleArena({required double scale, required Map<ScaleStart, ScaleGesture> registered, double minDelta = 0.01}) ActiveGesture?
Resolves a scale gesture from the registered map for the current scale magnitude. Returns the first eligible entry, or null if scale is below the commit threshold or no gesture qualifies.
scaleForCenter({required double center, required double basePos, required double baseHalfDim, required double displayLow, required double displayHigh, required ScaleResponse? response}) double
Per-axis scaleResponse: given the rect's center on the axis, returns the corresponding scale factor by reading the lerp between geometric endpoints. In-display zone end = "rect's near edge touches display edge, size = base * inDisplay.end"; past-display zone end = "rect's far edge touches display edge, size = base * pastDisplay.end".

Typedefs

AxisState = ({DragBound activeBound, DragDirectionState directionState, double progress})
Per-axis classification used by friction / fling lookups.
ScaleAxisState = ({ScaleSide activeSide, bool extending, bool pastDisplay, double progress})
Per-axis classification for the scale axis (parallel to AxisState for drag axes).