TimeTracker mixin

A mixin providing methods to records time-status changes.

  • The object can be started, paused, resumed, and ended.
  • To retrieve the current state use the getter status.
  • To retrieve the recorded time points use the getter dateTimePoints.
  • To retrieve the recorded time points as microseconds since epoch use the getter timePoints. Note: Every time the objects status changes a new time point is added.

Properties

dateTimePoints List<DateTime>
Returns the recorded time points of the object. Every time the object is paused or resumed an additional time point is added.
no setter
duration Duration
Returns the duration between the object start point and end point.
no setter
durationAsMicroseconds int
Returns the duration between the object start point and end point as microseconds.
no setter
durationOfPauses Duration
Returns the duration of all pauses added together. If the object is in status TimeStatus.paused, then the difference between DateTime.now and the last recorded time point is considered to be the duration of the last pause.
no setter
durationOfPausesAsMicroseconds int
Returns the duration of all pauses (in microseconds) added together If the object is currently in status TimeStatus.paused, then the difference between the last recorded time point and now is omitted.
no setter
endTime DateTime?
Returns the end time of the object or null if the status of the objects is not TimeStatus.ended.
no setter
hasEnded bool
Returns true is the current status is TimeStatus.ended and false otherwise.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasNotEnded bool
Returns true if the current status is not TimeStatus.ended and false otherwise.
no setter
hasNotResumed bool
Returns true if the current status is not TimeStatus.resumed and false otherwise.
no setter
hasNotStarted bool
Returns true if the current status is not TimeStatus.started and false otherwise.
no setter
hasResumed bool
Returns true is the current status is TimeStatus.resumed and false otherwise.
no setter
hasStarted bool
Returns true if the current status is TimeStatus.started and false otherwise.
no setter
isNotPaused bool
Returns true if the current status is not TimeStatus.paused and false otherwise.
no setter
isOtherThanReady bool
Returns true if the current status is not TimeStatus.ready and false otherwise.
no setter
isPaused bool
Returns true if the current status is TimeStatus.paused and false otherwise.
no setter
isReady bool
Returns true the current status is TimeStatus.ready and false otherwise.
no setter
lastTimePoint DateTime?
Returns the last recorded time point or null if the tracker is in state `TimeState.ready].
no setter
pauses List<int>
Returns a list containing the duration of completed pauses in microseconds.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startTime DateTime?
Returns the start time of the object or null if the tracker was not started yet.
no setter
status TimeStatus
Returns the current object status: TimeStatus.started, TimeStatus.paused, TimeStatus.resumed, or TimeStatus.ended.
no setter
timePoints List<int>
Returns the recorded time points as microseconds since epoch. Every time the object is paused or resumed an additional time point is added.
no setter
trackerHashCode int
no setter

Methods

end() → void
Sets the time status of the object to TimeStatus.ended. Adds a time point marking the completion time.
initTrackerfromJson(Json json) → void
Reads a json map and initializes the tracker status and time points.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause() → void
Sets the time status of the object to TimeStatus.paused if the current time status is TimeStatus.started or TimeStatus.resumed and adds a time point.
resume() → void
Sets the time status of the object to TimeStatus.resumed if the current status is TimeStatus.paused and adds a time point.
start() → void
Sets the time status of the object to TimeStatus.started if the current time status is TimeStatus.ready. Records the first time point.
toJson() → Json
inherited
toString() String
A string representation of this object.
inherited
trackerEqual(Object other) bool
Returns true if the two instances have the same time status and the same time points.
trackerToJson() → Json
Returns a json-encodable map representing the current TimeTracker status and the stored time points.
trackerToString() String

Operators

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

Static Methods

isValidTimeLine({required TimeStatus status, required List timePoints}) String
Checks if the provided time line is compatible with the provided time status. Returns a non-empty message if validation fails.

Constants

$status → const String
Json key for the variable status.
$timePoints → const String
Json key for the variable timePoints..