有没有一种方法可以使Animations不停止Flutter驱动程序?

时间:2019-08-08 11:43:54

标签: flutter flutter-test

FlutterDriver from flutter_driver暂停所有动作,直到不再播放动画为止。

我的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.
});

1 个答案:

答案 0 :(得分:4)

您可以使用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

相关问题