Timer class

Simple utility class that helps handling time counting and implementing interval like events.

Timer auto-starts by default.

NOTE: You can change the limit, but keep in mind that the timer won't start automatically if the limit is raised and the timer currently is stopped.

Constructors

Timer(double limit, {VoidCallback? onTick, bool repeat = false, bool autoStart = true, int? tickCount})

Properties

current → double
The current amount of seconds that has passed on this iteration
no setter
finished → bool
If the timer is finished, timers that repeat never finish
no setter
hashCode → int
The hash code for this object.
no setterinherited
limit ↔ double
getter/setter pair
onTick ↔ VoidCallback?
getter/setter pair
progress → double
A value between 0.0 and 1.0 indicating the timer progress
no setter
repeat ↔ bool
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tickCount → int?
final

Methods

isRunning() → bool
Whether the timer is running or not
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause() → void
Pause the timer (no-op if it is already paused).
reset() → void
Reset the timer to 0, but continue running if it currently is running.
resume() → void
Resume a paused timer (no-op if it is already running).
start() → void
Start the timer from 0.
stop() → void
Stop and reset the timer.
toString() → String
A string representation of this object.
inherited
update(double dt) → void

Operators

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