【问题标题】:Is there a way to make Animations not Halt Flutter driver?有没有办法让动画不停止颤振驱动程序?
【发布时间】:2019-08-08 11:43:54
【问题描述】:

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

【问题讨论】:

    标签: flutter flutter-test


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-02-24
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多