Countdown
CountdownText shows the time left until a deadline, such as when a virtual account expires: 14:59, or 1:04:09 when there is an hour or more.
A countdown reaching zero is not proof of non-payment; ask your backend for the payment status.


CountdownText.formatDuration(left);Variants
Section titled “Variants”Variants: remaining, warning, elapsed.
When the deadline passes
Section titled “When the deadline passes”The countdown stops at 00:00 and never goes negative. onElapsed is called once, after the frame, including when the deadline has already passed the first time the widget builds. Changing expiresAt starts a new countdown, and onElapsed can fire again for the new deadline.
Use onElapsed to ask your host for the status, not to show “expired”. A transfer made in the last second may still arrive.
Formatting outside the widget
Section titled “Formatting outside the widget”The static helpers do the same arithmetic without a widget:
final left = CountdownText.remaining(va.expiresAt, host.clock());final text = CountdownText.formatDuration(left); // "14:59"Which variant when
Section titled “Which variant when”| Situation | Variant / composition | Payment example |
|---|---|---|
| Virtual account expiry | remaining | Pass the host expiry and clock; elapsed is a display state, not a payment verdict. |
Use Status header for payment outcome.
States
Section titled “States”The host supplies the deadline and clock. Reaching zero calls onElapsed; it does not change the payment status.
Layout. The countdown reserves the width of the longest format it will show, so the text does not jump when 1:00:00 becomes 59:59.
Do and don’t
Section titled “Do and don’t”Do: Pass the host expiry and clock; elapsed is a display state, not a payment verdict.
Don’t: Infer payment failure from an elapsed timer.
Content guidelines
Section titled “Content guidelines”- Pair the countdown with the deadline itself (a date and time) so the person can plan, as the virtual account instructions do.
- Label it with what the deadline is for: “Pay before”, not “Timer”.
Accessibility
Section titled “Accessibility”- Digits are tabular, so the width does not change as they tick.
- Screen readers hear “Time remaining 14:59” (or the Indonesian equivalent).
- The countdown is never animated beyond its once-a-second text change.
CountdownText
class CountdownText extends StatefulWidget · lib/src/foundation/primitives.dart
Counts down to expiresAt using the host clock. Stops at zero and calls onElapsed once; reaching zero is not proof of non-payment.
| Parameter | Type | Default | Description |
|---|---|---|---|
expiresAt:required | DateTime | — | — |
clock:required | DateTime Function() | — | — |
onElapsed: | VoidCallback? | — | — |
style: | TextStyle? | — | — |
See also
Section titled “See also”The default style is the 15/20 label role in textPrimary, with tabular figures. A supplied style merges into that role; tabular figures remain enabled.