FixedTimestep class
Configuration + accumulator state for the fixed-timestep loop.
The Scheduler runs the fixed-timestep chain
(Schedules.fixedFirst → Schedules.fixedPreUpdate →
Schedules.fixedUpdate → Schedules.fixedPostUpdate →
Schedules.fixedLast) 0..maxCatchupSteps times per frame based on
the accumulated real-time delta. Users configure the cadence by
inserting this resource into the app before run(); if not
inserted, App provides a default 60Hz instance.
Example
App()
..insertResource(FixedTimestep(
stepDuration: const Duration(microseconds: 8333), // 120Hz
maxCatchupSteps: 3,
))
.run();
- Available extensions
Constructors
- FixedTimestep({Duration stepDuration = const Duration(microseconds: 16667), int maxCatchupSteps = 5})
Properties
- accumulatorSeconds → double
-
Current accumulator value, in seconds. Read-only diagnostic.
no setter
- alpha → double
-
Interpolation alpha for rendering (0..1) between the last completed
fixed step and the next. Render systems can use this to smooth
world-state changes over the visual frame.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxCatchupSteps → int
-
Maximum number of fixed steps to run in a single frame before
dropping the remaining accumulated time. Prevents a "spiral of
death" when a real frame runs long.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stepDuration → Duration
-
Target duration of one fixed step (default: 1/60 s).
final
- stepSeconds → double
-
One fixed step, in seconds.
no setter
- stepsThisFrame ↔ int
-
Number of fixed steps that ran in the most recent frame. Read-only
diagnostic; useful for a debug overlay.
getter/setter pair
Methods
-
addAccumulated(
double seconds) → void -
Available on FixedTimestep, provided by the FixedTimestepInternal extension
Adds real-timesecondsto the accumulator. Called byScheduler.runFixedIfDueat the top of each frame's fixed pass. -
consumeStep(
) → void -
Available on FixedTimestep, provided by the FixedTimestepInternal extension
Consumes one fixed step's worth of accumulated time. -
dropRemainder(
) → void -
Available on FixedTimestep, provided by the FixedTimestepInternal extension
Drops all remaining accumulated time — used when the catch-up cap is hit to avoid a spiral of death. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited