LoginSignup
0
0

More than 3 years have passed since last update.

[flutter_driver] Flutter統合テストでdriverアクションがフリーズしてしまう問題を解決する

Posted at

CircularProgressIndicatorなどのループアニメーションを含むWidgetがUIにあると、driver.tap()driver.screenshot()などのdriverへのアクションはフリーズします。
これは、flutter_driverにはUIの更新が終わるまでUIへの操作を待機させるframe syncという機構が備わっているからです。

test('test', () async => {
  // UIにプログレスバーなどのループアニメーションがあると実行されない
  // =>テストがタイムアウト
  await driver.tap(find.byValueKey('key'));
});

解決方法

runUnsynchronizedframe syncを無効にすればUIの更新終了を待たずに実行することができます

test('test', () async {
  await driver.runUnsynchronized(() async {
    // UIが更新途中でも実行される
    await driver.tap(find.byValueKey('key'));
  });
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0