Countdown class
A running count of the time to a moment, or since one.
Countdown(target: DateTime.now().add(const Duration(hours: 2)))
Countdown(target: launchedAt, type: CountdownType.up, format: 'D[d] HH:mm:ss')
The format decides both what is drawn and how often: a format asking for milliseconds is redrawn every frame, one that stops at seconds once a second, on the second. Nothing is redrawn while the drawn text would not change, so an hours-and-minutes countdown costs almost nothing to leave on screen.
Named Countdown rather than Timer because dart:async already has a
Timer, and the file that shows this widget is usually the same file that
needs the other one.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- Countdown
Constructors
-
Countdown({Key? key, DateTime? target, CountdownController? controller, CountdownType? type, String format = 'HH:mm:ss', VoidCallback? onFinish, ValueChanged<
Duration> ? onChanged, Widget builder(BuildContext context, String formatted)?, CountdownToken? token}) -
Creates a Countdown.
const
Properties
- builder → Widget Function(BuildContext context, String formatted)?
-
Wraps the formatted time — a place for a label, a prefix, an icon.
final
- controller → CountdownController?
-
Drives the count from outside the build — pausing above all, which no
arrangement of properties can express. See CountdownController.
final
- format → String
-
How the remaining time is written out.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onChanged
→ ValueChanged<
Duration> ? -
Called with the time left, or elapsed, whenever the count is redrawn.
final
- onFinish → VoidCallback?
-
Called once, when a downward count reaches the target. Never called
counting up, which has no end to reach.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- target → DateTime?
-
The moment counted towards, or from. Null when a controller holds it.
final
- token → CountdownToken?
-
Per-instance token overrides.
final
- type → CountdownType?
-
Whether the count runs towards target or away from it.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< Countdown> -
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, int wrapWidth = 65}) → 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