Skip to content
Get started
Menu
Get started

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.

Countdown values for long, short and expired payment deadlines.Countdown values for long, short and expired payment deadlines.
Light and dark variants
lib/src/foundation/primitives.dart
CountdownText.formatDuration(left);

Variants: remaining, warning, elapsed.

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.

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"
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.

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: Pass the host expiry and clock; elapsed is a display state, not a payment verdict.

Don’t: Infer payment failure from an elapsed timer.

  • 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”.
  • 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.

ParameterTypeDefaultDescription
expiresAt:requiredDateTime——
clock:requiredDateTime Function()——
onElapsed:VoidCallback?——
style:TextStyle?——

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.