有没有办法让动画不停止颤振驱动程序?



flutter_driver中的FlutterDriver暂停所有操作,直到不再播放动画。

我的 UI 涉及循环动画,我想在播放此类动画时点击集成测试中的某些内容。
一旦我进入一个具有循环动画的屏幕,除非有点击输入,否则不会停止,FlutterDriver在等待动画完成时只会超时(因此在我的集成测试中永远不会发生(。

基本上,默认情况下,所有像driver.tap这样的操作都将等待所有动画(至少由AnimationController创建(才能执行。

test('stop looping animation', () async {
// Navigated to a screen with a looping animation before that.
await driver.tap(find.byValueKey('stop_looping_animation')); // FlutterDriver will time out here.
});

您可以使用FlutterDriver.runUnsynchronized

test('stop looping animation', () async {
await driver.runUnsynchronized(() async {
await driver.tap(find.byValueKey('stop_looping_animation'));
});
});

有类似的问题,此评论有所帮助:https://github.com/flutter/flutter/issues/34503#issuecomment-503545683

最新更新