ClampingScrollSimulation class

An implementation of scroll physics that aligns with Android.

For any value of velocity, this travels the same total distance as the Android scroll physics.

This scroll physics has been adjusted relative to Android's in order to make it ballistic, meaning that the deceleration at any moment is a function only of the current velocity dx and does not depend on how long ago the simulation was started. (This is required by Flutter's scrolling protocol, where ScrollActivityDelegate.goBallistic may restart a scroll activity using only its current velocity and the scroll position's own state.) Compared to this scroll physics, Android's moves faster at the very beginning, then slower, and it ends at the same place but a little later.

Times are measured in seconds, and positions in logical pixels.

See also:

Inheritance

Constructors

ClampingScrollSimulation({required double position, required double velocity, double friction = 0.015, Tolerance tolerance = Tolerance.defaultTolerance})
Creates a scroll physics simulation that aligns with Android scrolling.

Properties

friction double
The amount of friction the particle experiences as it travels.
final
hashCode int
The hash code for this object.
no setterinherited
position double
The position of the particle at the beginning of the simulation, in logical pixels.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tolerance Tolerance
How close to the actual end of the simulation a value at a particular time must be before isDone considers the simulation to be "done".
getter/setter pairinherited
velocity double
The velocity at which the particle is traveling at the beginning of the simulation, in logical pixels per second.
final

Methods

dx(double time) double
The velocity of the object in the simulation at the given time.
override
isDone(double time) bool
Whether the simulation is "done" at the given time.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
x(double time) double
The position of the object in the simulation at the given time.
override

Operators

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