CountDownWidget constructor
- 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
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.
Implementation
const CountDownWidget({
Key? key,
required this.duration,
required this.builder,
this.stepDuration = const Duration(seconds: 1),
this.onControllerReady,
this.onExpired,
this.onFinish,
this.onDurationRemainChanged,
this.durationExpired = const Duration(),
this.runWhenSleep = true,
this.autoStart = true,
}) : super(key: key);