CountDownWidget class

builder is function callback return Widget by durationRemain, it will be called when durationRemain Changed

onControllerReady is function callback, it will be called when CountDownTimerController is ready to use

onExpired it will be called when duration is less than or equal to durationExpired

onFinish it will be called when countdown finish

onDurationRemainChanged it will be called when duration changed

durationExpired is duration to check when countdown reach to timeExpire, default is 0

ex: if you want to set time expire when countdown to 00:30, set durationExpired = Duration(seconds: 30)

duration is total time you want to countdown, ex: you want countdown from 01:20 -> 00:00 set duration = Duration(seconds: 120)

stepDuration is the duration of step count, default is 1 second

runWhenSleep default is true

-- if true: onDurationRemainChanged will be called even when the phone turns off the screen

-- if false: onDurationRemainChanged will not be called when the phone turns off the screen

Note, whether you set runWhenSleep to true or false, when the app is reopened, the timer will still count the amount of time you turn off the screen, but it won't count if you call the controller.pause function.

Inheritance

Constructors

CountDownWidget({Key? key, required Duration duration, required BuildWidgetByDuration builder, Duration stepDuration = const Duration(seconds: 1), OnControllerReady? onControllerReady, VoidCallback? onExpired, VoidCallback? onFinish, ValueChanged<Duration>? onDurationRemainChanged, Duration durationExpired = const Duration(), bool runWhenSleep = true, bool autoStart = true})
builder is function callback return Widget by durationRemain, it will be called when durationRemain Changed
const

Properties

autoStart bool
autoStart is flag to config timer will auto start or not, default is true
final
builder BuildWidgetByDuration
Widget builder when duration remain changed
final
duration Duration
total duration you want to count
final
durationExpired Duration
if duration remain is less than or equal durationExpired, onExpired will be called, default durationExpired = const Duration()
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onControllerReady OnControllerReady?
callback return CountDownController when it ready to use
final
onDurationRemainChanged ValueChanged<Duration>?
callback when duration remain changed
final
onExpired VoidCallback?
callback when timer reach to durationExpired
final
onFinish VoidCallback?
callback when timer is done
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
runWhenSleep bool
runWhenSleep default is true
final
stepDuration Duration
the duration of step count
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
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