ChaseSpring class

A critically damped spring chasing a MOVING target, integrated step by step by its owner's clock (a Ticker's elapsed deltas).

Why this exists instead of a controller: retargeting a simulation per pointer event starves it - a high-frequency mouse restarts the simulation before it ever ticks and the value freezes while the pointer moves. The chase inverts the flow: events only move target, and the owner integrates exactly once per frame.

Critically damped by construction (damping = 2 * sqrt(stiffness)): tight under a finger, no oscillation of its own - character belongs to whatever plays after the chase hands off its velocity.

Constructors

ChaseSpring({double stiffness = 900})
Creates a chase with the given stiffness.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stiffness double
Spring stiffness; higher chases tighter. The damping is derived as 2 * sqrt(stiffness), keeping the chase critically damped.
final
target Offset
The moving target; writing a NEW position wakes a resting chase.
getter/setter pair
value Offset
Where the spring is now. Seed it through grab.
getter/setter pair
velocity Offset
The spring's current velocity in px/s - hand it to whatever takes over on release, so a flick lands with its momentum.
getter/setter pair

Methods

grab(Offset at, {Offset velocity = Offset.zero}) → void
Seeds the chase at at (target included), carrying velocity in - grabbing a surface mid-return stays continuous.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
tick(double dt) bool
Advances by dt seconds. Returns whether value changed - false once the chase has come to rest (after snapping exactly onto the target once), so the owner can skip downstream work instead of re-rendering epsilon motion every frame under a motionless finger.
toString() String
A string representation of this object.
inherited

Operators

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