Timer with tickCount stays finished after start() or reset()
维护者通常 1 天内回复
评估
调研方向
从 Timer 的实现及其测试入手,找到 reset()、start()、stop() 和 _callTicker;issue 指出了 tick 计数器以及达到上限时的行为。用 tickCount: 2 重现示例,然后检查重启和重置是否允许再 tick 两次,以及计时器在达到上限后是否报告 finished。
由索引模型根据 Issue 内容生成。
描述
What happened?
A Timer (or TimerComponent) with tickCount never resets its tick counter. start(), stop() and reset() only set current back to 0, so once the timer has ticked tickCount times:
finishedis stilltrueright afterstart(), even though the timer is running again. ATimerComponentwithremoveOnFinish: trueis removed on its next update.- The restarted timer ticks once and stops, instead of ticking
tickCounttimes again.
reset() part way through has the same problem: the ticks counted before the reset still count towards the limit.
What do you expect?
start() starts the timer from 0, as its docs say, so it should tick tickCount times again and not be finished until it has. reset() should also reset the ticks.
How can we reproduce this?
var count = 0;
final timer = Timer(
period: 1,
repeat: true,
tickCount: 2,
onTick: () => count++,
);
timer.update(1.1);
timer.update(1.1);
print(count); // 2
print(timer.finished); // true
timer.start();
print(timer.finished); // true, expected false
timer.update(1.1);
timer.update(1.1);
print(count); // 3, expected 4
What steps should take to fix this?
Reset _currentTick in Timer.reset() (which start() and stop() call). When the tick limit is reached, _callTicker calls stop() today; it would need to set _current to 0 and pause instead, so that the timer still reports finished afterwards.
Affected platforms
All
Other information
Flame main at a0044089 (flame 2.0.0-dev.1), Flutter 3.47.9 stable. tickCount was added in #3552.
Are you interested in working on a PR for this?
- I want to work on this
- 主要语言
- Dart
- 星标
- 10.8k
- 派生
- 1.1k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 61
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
flame-engine/flame 的其他 Issue
-
`CameraComponent.follow` follows the local position of a nested target可能已有人在做 @ufrshubham 于 1 天前认领。 未关闭bug
flame-engine/flame#4238 · 已指派 1 人 ·
维护者通常 1 天内回复
-
`ComponentPool` returns components to the pool while they are still in use, and loses components removed before mounting可能已有人在做 @ufrshubham 于 18 天前认领。 未关闭bug
flame-engine/flame#4191 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Move the flame_studio debugging features to flame_devtools可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭enhancement
难度 5/5 一周以上 新手友好度 35/100
flame-engine/flame#4176 ·
维护者通常 1 天内回复
-
discussion enhancement
难度 5/5 一周以上 新手友好度 25/100
flame-engine/flame#4175 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
flame-engine/flame#4174 ·
维护者通常 1 天内回复
查看 flame-engine/flame 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
spotiflacapp/SpotiFLAC-Mobile#935 ·
-
documentation
难度 2/5 1-3 小时 新手友好度 76/100
chriskelly/wish-together#193 ·
维护者通常 1 天内回复
-
area: player feature request
难度 2/5 1-3 小时 新手友好度 65/100