GlassSpring class
A damped spring that eases a value towards a target, keeping its velocity when the target changes mid-flight, as Glisse's springs do.
Each frame it steps by the spring's exact solution, so it is stable at any frame rate. stiffness and damping are per unit mass.
- Inheritance
-
- Object
- ChangeNotifier
- GlassSpring
- Implemented types
Constructors
- GlassSpring.new({required TickerProvider vsync, double value = 0, required double stiffness, required double damping})
-
Creates a spring at rest on
value, driven by a ticker fromvsync.
Properties
- damping → double
-
How strongly the spring resists its own motion, per unit mass.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isMoving → bool
-
Whether the spring is still moving, so its ticker is running.
no setter
- reduceMotion ↔ bool
-
When true, every change lands at once, as when the platform asks for
reduced motion.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stiffness → double
-
How hard the spring pulls towards target, per unit mass.
no setter
- target → double
-
The value the spring is heading for.
no setter
- value → double
-
The current value of the object. When the value changes, the callbacks
registered with addListener will be invoked.
no setteroverride
- velocity → double
-
How fast value is changing, in units per second.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
jump(
double value, {double velocity = 0}) → void -
Jumps to
valueand keeps moving atvelocitytowards the target. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
set(
double target, {bool instant = false}) → void -
Springs towards
target, or jumps there wheninstant. -
stop(
) → void - Stops where it is.
-
toString(
) → String -
A string representation of this object.
inherited
-
tune(
double stiffness, double damping) → void - Changes how the spring moves from now on, keeping where it is and how fast.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited