GameClock constructor
GameClock(
{ - Duration maxDeltaPerTick = const Duration(milliseconds: 250),
- Duration? fixedStep,
})
Implementation
GameClock({
this.maxDeltaPerTick = const Duration(milliseconds: 250),
Duration? fixedStep,
}) : _fixedStep = fixedStep {
// BUG-54: with no validation, `fixedStep: Duration.zero` (or negative)
// made `advance()`'s `while (_accumulator >= fixedStep) { _accumulator
// -= fixedStep; ... }` loop condition permanently true while never
// shrinking `_accumulator` — an infinite loop hanging the UI thread the
// moment the game called `advance()`. A plain `if`/`throw` (not
// `assert`) so it still fires in release builds.
final step = fixedStep;
if (step != null && step <= Duration.zero) {
throw ArgumentError.value(fixedStep, 'fixedStep', 'must be > 0');
}
}