countman library

Classes

AnimatedCounter
Animated rolling-digit counter backed by CustomPainter.
AnimatedCounterBuilder
Animated rolling-digit counter using Flutter's widget tree.
AnimatedCounterController
动画计数组件的命令式控制器,由当前绑定的展示组件响应命令。
AnimatedCounterStyle
Visual style for AnimatedCounter and AnimatedCounterBuilder.
BarCountdown
A linear progress-bar countdown display. Composes CountdownBuilder.
BarCounter
A linear progress-bar counter display — the fill-toward-a-goal counterpart to BarCountdown. Progress = (value - from) / (to - from).
BarPainter
Draws a filled rounded-rect bar over a track — the shared rendering core for BarCountdown (bar shrinks) and BarCounter (bar grows). Both widgets only differ in how they compute progress; the fill math lives here once.
BarStyle
Visual style for the bar displays — shared by BarCounter and BarCountdown (see the BarCounterStyle / BarCountdownStyle aliases).
CardCountdown
A flip-card countdown display. Each time unit (H / M / S) is rendered as a card that animates when the digit changes.
CardCountdownProvider
Shares default style/size/timing config across a subtree of CardCountdowns, so a whole screen of cards doesn't need to repeat cardColor:/textStyle:/duration: etc. on every instance.
CardCountdownProviderData
Resolved config + shared glyph cache exposed to descendant CardCountdowns by CardCountdownProvider.
CardCountdownStyle
Visual style for CardCountdown.
CardGeometry
Resolved geometry for one CardCountdown paint pass — cell positions, separator/label centers, and the overall canvas size.
CardGlyphCache
有界字形缓存,最多保留 512 个段落;删除、替换和清空均负责 dispose。 使用与 Map 相同的接口,例如 cache.putIfAbsent((text, style), create)。
CardModel
Mutable, painter-visible animation state for one CardCountdown instance. Digit ticks and transition progress mutate this directly — no setState — the painter's repaint listenable (the shared Animation) is what schedules the repaint.
Cell
Layout of one digit cell within a CardCountdown, resolved by its _measure() and consumed by FlipCardPainter.
ClockPlugin<T extends ClockTask>
时钟类引擎(倒计时、正计时)的基类。
ClockTask
由时钟锚点驱动的任务,按自己的显示桶边界更新。 倒计时(截止点在前)与正计时(起点在后)共用。
Countdown
Countdown engine — drives Duration-based timers on the shared ticker. Each instance is an independent task queue (= a "group").
CountdownBuilder
A widget that drives a countdown timer on the shared ticker and exposes the remaining Duration via a builder callback.
CountdownController
倒计时展示组件的命令式控制器,结束后 reset 会请求组件重启。
CountdownFormat
Built-in duration formatters.
CountdownHandle
Returned by Countdown.add.
CountdownOptions
Options for a countdown task added via Countdown.add or countdown.
CountdownProvider
Supplies default configuration and an optional shared Countdown group to every countdown display widget below it.
CountdownTask
倒计时内部任务状态;锚点是整数微秒,热路径不构造对象。
Counter
Counter engine — drives number interpolation on the shared ticker. Each instance is an independent task queue (= a "group").
CounterBuilder
A widget that drives a counter animation on the shared ticker and exposes the current value via a builder callback.
CounterFormat
两种动画计数器共享的不可变格式配置;空字段回退到组件平铺参数。
CounterHandle
Returned by Counter.add. Allows the caller to retarget or cancel the animation without holding a reference to the plugin.
CounterOptions
Options for a counter animation task.
CounterPainter
常驻数字画笔;原地更新数位、方向及有限档位颜色,缓存排版段落。
CounterProvider
Supplies default configuration and an optional shared Counter group to every counter display widget below it.
CounterTask
Internal task state.
CounterTimeline
两种动画计数器共享的不可变时间轴;非空字段覆盖同名平铺参数,空字段回退。
CounterTransition
Composable digit transition: pick one motion and layer independent scale / fade / blur modifiers — any combination, no enum explosion. Named presets (slide, fade, scale, rotate, flip, flipFade, slideScale, blur) cover the common looks.
CounterValueController
计数展示组件的命令式控制器,完成后的 update 会请求组件重启任务。
Countman
Shared vsync ticker — one scheduleFrameCallback drives all plugins.
CountmanClock
微秒精度的墙钟与单调钟抽象,供倒计时与正计时引擎读取时间。 相对时长(duration)按单调钟锚定,绝对截止(deadline)按墙钟锚定。 可用 Countdown(clock: ManualCountmanClock()) 注入确定性时钟。
CountmanContext
Capabilities injected into a plugin when it is registered. Plugins hold a reference and call requestFrame whenever they enqueue a new task and need the ticker to (re-)start.
CountmanPlugin
Plugin interface. Each instance owns its own task queue and is registered once on the shared Countman ticker.
CountmanProvider
One-stop provider that configures all three families at once, so a page using counters, countdowns AND stopwatches doesn't need to hand-nest CounterProvider / CountdownProvider / ElapsedProvider.
CountmanScope<P>
Shared inherited scope carrying the default configuration a CounterProvider / CountdownProvider / ElapsedProvider hands down to descendant countman display widgets.
CountmanTask
Base state for a single task owned by a TaskQueuePlugin.
CountmanTextStyle
Visual style for the text displays — shared by TextCounter, TextCountdown and TextElapsed (see the TextCounterStyle / TextCountdownStyle / TextElapsedStyle aliases in those files).
CountmanTheme
countman 各展示组件的主题默认样式,通过 ThemeData.extensions 注入。
DialArcConfig
Configuration for one decorative segmented arc ring.
DialColors
The five zone colours that drive tick / arc / digit tinting.
DialCountdown
DialCountdownStyle
A circular dial countdown display that replicates the ring.ts renderer in Flutter using CustomPainter.
DialInnerConfig
Configuration for the innermost progress ring.
DialTicksConfig
Configuration for the outermost tick ring.
DigitColumnLayout
DigitPhase
Mutable output holder for resolveDigitPhase. Callers keep ONE instance and reuse it every frame so the paint/build hot path stays allocation-free (a record return would heap-allocate per digit per frame in a perf-critical counter).
Elapsed
Elapsed-time engine — drives open-ended "stopwatch" timers on the shared ticker. Each instance is an independent task queue (= a "group").
ElapsedBuilder
Low-level open-ended elapsed-time (stopwatch) widget that exposes the current TimeParts via a builder — the elapsed counterpart to CountdownBuilder. Starts at zero on mount and counts up indefinitely until removed or ElapsedController.cancelled.
ElapsedController
正计时展示组件的命令式控制器,取消后 reset 会请求组件重启。
ElapsedHandle
Returned by Elapsed.add. 正计时句柄,终态后的暂停、恢复与重置均无操作。
ElapsedOptions
Options for an elapsed-time task added via Elapsed.add or elapsed.
ElapsedProvider
Supplies default configuration and an optional shared Elapsed group to every elapsed-time display widget below it.
ElapsedTask
正计时内部任务状态;以单调钟锚定起点,不受墙钟变化影响。
FlipCardPainter
Paints one CardCountdown — every digit, separator and label — as a single CustomPainter repainted in place, not a widget subtree rebuilt per digit.
LazyDefault<T extends CountmanPlugin>
Holds a lazily-created, auto-registered default plugin instance. Replaces the per-engine _default / _registered bootstrap and the matching Countman.destroy() reset boilerplate.
ManualCountmanClock
可手动推进的时钟,供业务模拟和测试使用,无需真实等待。
OdometerCounter
A sliding-digit "odometer" counter. Now a thin preset over AnimatedCounter with CounterTransition.slide and odometer defaults (fixed-width leading zeros). The previous standalone painter was removed — AnimatedCounter's slide is the same look — so most rendering knobs are inherited from it.
OdometerCounterStyle
Visual style for OdometerCounter.
OffsetClock
仅偏移墙钟的包装器,适用于服务器校时。
RingCountdown
A circular arc countdown display. Composes CountdownBuilder.
RingCounter
A circular arc counter display — the fill-toward-a-goal counterpart to RingCountdown. Progress = (value - from) / (to - from).
RingPainter
Draws a circular arc over a track — the shared rendering core for RingCountdown (arc depletes) and RingCounter (arc fills). Both widgets only differ in how they compute progress; the arc math lives here once.
RingStyle
Visual style for the ring displays — shared by RingCounter and RingCountdown (see the RingCounterStyle / RingCountdownStyle aliases).
StartScheduler
Frame-based batch scheduler for widget animation starts.
SystemClock
系统时钟;底层保留 countdownClock/elapsedClock 注入点。 首次读取时懒注册生命周期监听;前台墙钟跳变不会补到单调钟。
TaskQueuePlugin<T extends CountmanTask>
Shared boilerplate for every countman engine: task map, id allocator, context wiring, add/remove/dispose plumbing, and the per-frame tick skeleton (empty-check → first-frame render → per-task step → deferred removal of completed tasks).
TextCountdown
A Text-based countdown widget with optional prefix/suffix.
TextCounter
A Text-based counter widget with optional prefix/suffix.
TextElapsed
Displays an open-ended elapsed-time counter — a stopwatch, not a countdown. Starts at zero the moment it's mounted and counts up indefinitely until removed or ElapsedController.cancelled.
TimeParts
Read-only decomposition of a Duration into its calendar components, shared per task: the owning countdown/elapsed task computes it once per tick into a reused fixed-length backing list (zero per-frame allocation), and every consumer of that task — formatters, progress widgets, the flip-card's per-unit cells — reads the same instance instead of each recomputing the %/~/ math.

Enums

CountdownRounding
倒计时的显示取整方式,由 CountdownOptions.rounding 选用。
CountdownType
Per-digit transition used by CardCountdown when a value changes.
CounterMotion
Primary per-digit movement for CounterTransition. Exactly one applies; CounterTransition.scale / .fade / .blur layer on top of it.
CountmanRunState
控制器的运行状态,供展示组件与业务代码统一观察。
NumeralSystem
Predefined numeral systems for internationalization.
SlideEffect
Enter/exit behavior for a CountdownType.slide/CountdownType.flip digit's scale (CardCountdown.scaleEffect) or opacity (CardCountdown.opacityEffect).
StaggerDirection
The direction in which the stagger effect propagates across digits.

Mixins

CountmanRunStateNotifier
为控制器提供可监听的运行状态的 mixin。

Properties

countdownClock ↔ DateTime Function()
SystemClock 墙钟的底层时间源,默认 DateTime.now。 放在 core/ 里,引擎之间不必为读时钟互相依赖。
getter/setter pair
defaultCountdown → Countdown
The default Countdown instance (interval = 1 s) used by CountdownWidget when no plugin is provided. Auto-registered with Countman on first access.
no setter
defaultCountdownMs → Countdown
The default precise Countdown instance (interval: 0 — processes every frame) used by widgets with precise: true when no plugin is given. Lets sub-second formatters (CountdownFormat.msTenths / CountdownFormat.msMillis) update smoothly without hand-wiring a group. Auto-registered with Countman on first access.
no setter
defaultCounter → Counter
The default shared Counter instance. Auto-registered with Countman on first access.
no setter
defaultElapsed → Elapsed
The default Elapsed instance (interval = 1 s) used by TextElapsed when no plugin is provided. Auto-registered with Countman on first access.
no setter
defaultElapsedMs → Elapsed
The default precise Elapsed instance (interval: 0 — processes every frame) used by widgets with precise: true when no plugin is given. Auto-registered with Countman on first access.
no setter
elapsedClock ↔ Duration Function()
SystemClock 单调钟的底层时间源;测试结束后应恢复原函数。
getter/setter pair

Functions

applyRotateX(Canvas canvas, Offset center, double angle, double perspective, void draw()) → void
Applies a perspective rotateX transform around center for the duration of draw, then restores the canvas.
countdown(CountdownOptions opts) → CountdownHandle
Add a countdown using the default shared Countdown instance.
countdownAnchorOf(Object to, {CountmanClock? clock}) → ({DateTime? deadline, Duration? duration})
把组件的 to 解析成 CountdownOptions 的锚点:Duration 走相对时长 (duration,单调钟锚定),其余类型解析为绝对截止(deadline,墙钟锚定)。 返回的记录里 duration 与 deadline 恰有一个非空。 例如 countdownAnchorOf(Duration(minutes: 5)) 得到 (duration: 5min, deadline: null)。
counter(CounterOptions opts) → CounterHandle
Add a counter animation using the default shared Counter instance. Auto-registered with Countman on first call.
elapsed(ElapsedOptions opts) → ElapsedHandle
Add an elapsed-time timer using the default shared Elapsed instance.
isAllNinesTarget(int n) → bool
True when n consists entirely of 9s (9, 99, 999, …): (n + 1) is a power of ten. Used to detect targets where digit interpolation stalls, animating to n − ε instead and snapping at completion.
remainingUntil(Object to, {CountmanClock? clock}) → Duration
Returns the remaining Duration until the deadline described by to, clamped to Duration.zero if already past. A Duration is returned as-is (relative lengths do not drift between two clock reads); other types are resolved against the wall clock of clock (defaults to CountmanClock.system).
resolveDeadline(Object to, {CountmanClock? clock}) → DateTime
Converts to to an absolute DateTime deadline.
resolveDigitPhase(DigitPhase out, {required bool fast, required int fastFrom, required int fastTo, required double position, required bool increasing, required int targetDigit, required double target, required bool hasTarget, double eps = 1e-3}) → void
Resolves the odometer triple a single digit column renders THIS frame INTO out, shared by the painter fast-path (CounterPainter.resolveColumnPhase) and the widget-tree path (DigitColumn) so the trajectory + end-of-roll ghost-prevention math lives in ONE tested place instead of being mirrored.

Typedefs

BarCountdownStyle = BarStyle
Visual style for BarCountdown. Alias of the shared BarStyle.
BarCounterStyle = BarStyle
Visual style for BarCounter. Alias of the shared BarStyle.
CountdownRelaunch = void Function({Duration? duration})
由展示组件调用的任务重启函数,业务代码不要直接调用。 duration 为空时采用组件配置;无返回值。例如绑定时传入 relaunch: _relaunch。
CounterPainterBuilder = CounterPainter Function({String decimalSeparator, required Size digitSize, required List<double> digitValues, required AxisDirection flipDirection, required int fractionDigits, required List<int> groupingPattern, required bool hideLeadingZeroes, required bool increasing, double numberAlignment, String numeralMapper(int)?, required NumeralSystem numeralSystem, EdgeInsets padding, required Listenable repaint, TextStyle? separatorStyle, required TextStyle style, String? thousandSeparator, required CounterTransition transition})
Factory signature for AnimatedCounter.painterBuilder. Receives the exact arguments the default CounterPainter would be built with, so a custom implementation can subclass CounterPainter and forward them (overriding only the drawing methods it cares about) while keeping the in-place update() / repaint contract the fast path relies on.
CounterRelaunch = void Function({Curve? curve, Duration? duration, required double to})
由展示组件调用的任务重启函数,业务代码不要直接调用。 to 为目标值,duration、curve 为空时沿用组件配置;无返回值。 例如展示组件绑定时传入 relaunch: _relaunch。
DurationFormatter = String Function(TimeParts parts)
Formatter function type for CountdownWidget / TextElapsed. Receives the shared per-task TimeParts (pre-decomposed d/h/m/s/ms) rather than a raw Duration, so a formatter reads components directly with no % math.
RingCountdownStyle = RingStyle
Visual style for RingCountdown. Alias of the shared RingStyle.
RingCounterStyle = RingStyle
Visual style for RingCounter. Alias of the shared RingStyle.
TextCountdownStyle = CountmanTextStyle
Visual style for TextCountdown. Alias of the shared CountmanTextStyle.
TextCounterStyle = CountmanTextStyle
Visual style for TextCounter. Alias of the shared CountmanTextStyle.
TextElapsedStyle = CountmanTextStyle
Visual style for TextElapsed. Alias of the shared CountmanTextStyle.