AnimatedCounterController class

动画计数组件的命令式控制器,由当前绑定的展示组件响应命令。

传给 AnimatedCounter.controller(或 AnimatedCounterBuilder.controller)后, 可调用 animateTo、jumpTo、pause、resume、stop、restart、repeat、 reverse。通过 runState / runStateListenable 观察 idle / running / paused / completed 四种运行状态,通过 status / addStatusListener 观察方向与端点状态。

示例:

final c = AnimatedCounterController();
c.runStateListenable.addListener(() => print(c.runState));
// AnimatedCounter(controller: c) 之后:
c.animateTo(100);
Inheritance
Mixed-in types

Constructors

AnimatedCounterController({num initialValue = 0})
创建控制器;initialValue 为 value 的初值。

Properties

hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
overrideDuration → Duration?
本次命令临时覆盖的时长(jumpTo 为 Duration.zero);null 表示沿用组件配置。
no setter
runState → CountmanRunState
当前运行状态,初始为 CountmanRunState.idle;总是最新值。
no setterinherited
runStateListenable → ValueListenable<CountmanRunState>
可监听的运行状态;仅在状态真正变化时通知,不要手动 dispose。 组件挂载等构建期写入的变化会在当帧结束后再通知,避免监听者在构建期间 setState。
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
status → AnimationStatus
当前播放方向或端点状态;pause 保持原方向,reverse 到起点发 dismissed。 例如 controller.status == AnimationStatus.reverse。
no setter
value → num
当前目标值。
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
addStatusListener(AnimationStatusListener listener) → void
添加播放状态监听。
animateTo(num targetValue) → void
动画滚动到 targetValue,使用组件配置的时长。
dispose() → void
释放控制器及运行状态通知器。
override
disposeRunState() → void
释放状态通知器;控制器自身被销毁时调用,调用后不得再监听或写入。
inherited
jumpTo(num targetValue) → void
立即跳到 targetValue,不播放动画。
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
pause() → void
暂停当前动画;仅在运行中有效。
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
removeStatusListener(AnimationStatusListener listener) → void
移除播放状态监听。
repeat({bool reverse = false}) → void
循环播放;reverse 为 true 时每轮结束后交换端点往返。
restart() → void
从当前端点的起点重新播放。
resume() → void
恢复被暂停的动画;仅在暂停态有效。
reverse() → void
反向播放:交换起止端点,从当前位置往回走。
stop() → void
停止动画并清掉待启动动作,状态回到 idle。
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited