TimeBuilder class

Very efficient timer, which rebuilds only when needed:

  • Compatible with DevTools "slow animations", which reduce the speed of AnimationControllers.
  • Compatible with clock changes, allowing for testing (skip frames to target a specific moment in time).
  • The animation is "muted" when the widget associated with the SingleTickerProviderStateMixin is not visible.

Based on Rémi Rousselet's code: https://gist.github.com/rrousselGit/beaf7442a20ea7e2ed3f13bbd40984a8 See explanation here: https://dash-overflow.net/articles/why_vsync/

Inheritance

Constructors

TimeBuilder({Key? key, required TimerWidgetBuilder builder, required IfRebuilds ifRebuilds, IsFinished? isFinished})
const
TimeBuilder.animate({Key? key, required TimerWidgetBuilder builder, IsFinished? isFinished})
Rebuilds in every frame.
const
TimeBuilder.countdown({Key? key, required DateTime start, required int seconds, required CountdownWidgetBuilder builder})
Creates a countdown, from the given start DateTime. Will call the builder, which is a CountdownWidgetBuilder, once per second, util the countdown reaches zero.
factory
TimeBuilder.eachHour({Key? key, int? hours, required TimerWidgetBuilder builder})
Rebuilds each hour. For example, this will show a clock that rebuilds each hour:
TimeBuilder.eachMillisecond({Key? key, required TimerWidgetBuilder builder})
Rebuilds each millisecond.
const
TimeBuilder.eachMinute({Key? key, int? minutes, required TimerWidgetBuilder builder})
Rebuilds each minute. For example, this will show a clock that rebuilds each minute:
TimeBuilder.eachSecond({Key? key, int? seconds, required TimerWidgetBuilder builder})
Rebuilds each second. For example, this will show a clock that rebuilds each second:

Properties

builder TimerWidgetBuilder
final
hashCode int
The hash code for this object.
no setterinherited
ifRebuilds IfRebuilds
final
isFinished IsFinished?
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _TimeBuilderState
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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