MyTimerController class

Programmatic remote control for a MyTimer widget.

Pass an instance to MyTimer(controller: ...) and then drive the timer from anywhere in your app:

final c = MyTimerController(onComplete: () => print('done!'));
MyTimer(controller: c, duration: const Duration(minutes: 5));
// later...
c.pause();
c.resume();
c.add(const Duration(seconds: 30));

Constructors

MyTimerController({void onTick(Duration remaining)?, VoidCallback? onComplete})

Properties

elapsed → Duration
Time elapsed since the timer was first started (after seeks/resets).
no setter
hashCode → int
The hash code for this object.
no setterinherited
isAttached → bool
Whether this controller is currently attached to a live MyTimer widget. Method calls are safe no-ops when not attached, so it is rarely needed.
no setter
isCompleted → bool
Whether the underlying timer has reached its configured duration.
no setter
isPaused → bool
Whether the underlying timer has been started, is not running, and has not yet completed.
no setter
isRunning → bool
Whether the underlying timer is currently ticking.
no setter
onComplete ↔ VoidCallback?
Fires once when the timer reaches its configured duration.
getter/setter pair
onTick ↔ void Function(Duration remaining)?
Fires on every UI tick with the current remaining time.
getter/setter pair
remaining → Duration
Time remaining until the timer completes.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(Duration delta) → void
Adds delta to the elapsed time.
attachEngine(MyTimerEngine engine) → void
detachEngine() → void
getTimer() → Duration
Returns the value currently being displayed: remaining time for count-down mode, elapsed time for count-up mode.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause() → void
Pauses the timer while preserving elapsed time.
reset() → void
Resets elapsed time to zero. Does not auto-start.
resume() → void
Resumes the timer from where it was paused.
seek(Duration position) → void
Jumps to position within the timer's duration. Preserves running state.
start() → void
Starts (or resumes) the timer.
stop() → void
Pauses the timer while preserving elapsed time. Alias for pause. Kept for backwards compatibility with 1.x — prefer pause.
subtract(Duration delta) → void
Subtracts delta from the elapsed time.
toString() → String
A string representation of this object.
inherited

Operators

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