PhysicsSimulator class abstract

Base contract for physics simulations.

All simulations produce position and velocity values as a function of time. They are used by MotionEngine.samplePhysics and by physics-based curves.

Implementations:

  • SpringSim — mass-spring-damper
  • FrictionSim — exponential deceleration (fling/scroll)
  • GravitySim — uniform acceleration (gravity, projectiles)
  • MagneticSim — inverse-square attraction (snap-to-point)
Implementers

Constructors

PhysicsSimulator()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
id String
Unique identifier for this simulator type.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

isDone(double t) bool
True when the simulation has effectively come to rest.
normalized(double t, {required double from, required double to}) double
Normalizes position to 0.0, 1.0 based on from and to. Useful for driving AnimationController.value.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
position(double t) double
Position at time t (seconds).
sample({double durationSec = 2.0, int sampleHz = 60}) List<double>
Samples the simulation at sampleHz for durationSec seconds.
settleDuration({double maxTime = 10.0, int resolution = 120}) double
Returns the time (seconds) at which isDone first becomes true, sampled at resolution steps per second. Returns maxTime if never done.
toString() String
A string representation of this object.
inherited
velocity(double t) double
Velocity at time t (units/second).

Operators

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