StopwatchModel class

A stopwatch model that counts up from zero.

The stopwatch counts elapsed time, ticking at interval intervals. Unlike a timer, the stopwatch counts up and has no timeout.

Example:

final stopwatch = StopwatchModel();
final (model, cmd) = stopwatch.init();
// Start the stopwatch
final (model2, cmd2) = model.startCmd();
Inheritance

Constructors

StopwatchModel({Duration interval = const Duration(milliseconds: 100), DateTime nowProvider()?})
Creates a new stopwatch model.

Properties

elapsed → Duration
Returns the elapsed duration.
no setter
hashCode → int
The hash code for this object.
no setterinherited
id → int
Returns the internal ID for this stopwatch.
no setter
interval → Duration
How often the stopwatch ticks.
final
running → bool
Returns whether the stopwatch is currently running.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tag → int
Returns the tag for this stopwatch instance.
no setter

Methods

copyWith({Duration? elapsed, Duration? interval, bool? running, int? id, int? tag}) → StopwatchModel
Creates a copy of this model with the given fields replaced.
init() → Cmd?
Initializes the stopwatch.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → Cmd
Creates a command to reset the stopwatch.
start() → Cmd
Creates a command to start the stopwatch.
stop() → Cmd
Creates a command to stop the stopwatch.
toggle() → Cmd
Creates a command to toggle the stopwatch on/off.
toString() → String
A string representation of this object.
inherited
update(Msg msg) → (StopwatchModel, Cmd?)
Updates the stopwatch based on incoming messages.
override
view() → String
Returns the view of the stopwatch.
override

Operators

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