Add await or ignore lint to flutter_driver unawaited callsites#183334
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses unawaited_futures lint warnings by adding await or // ignore comments. While the changes are generally good, there are a few places where await should be used instead of ignoring the future to prevent potential race conditions in tests. I've also suggested improvements for error handling in scrollUntilVisible to preserve stack traces and for a new test to make it more idiomatic.
| // ignore: unawaited_futures | ||
| driver.tap(textfield); |
There was a problem hiding this comment.
The driver.tap method returns a Future that completes when the tap command has been processed. By ignoring it with // ignore: unawaited_futures, the following Future.delayed might start executing before the tap is effective. This could lead to race conditions or flaky tests. It's safer to await the tap operation to ensure sequential execution.
| // ignore: unawaited_futures | |
| driver.tap(textfield); | |
| await driver.tap(textfield); |
There was a problem hiding this comment.
Ignoring because it seems intentional from the Future.delayed below.
| // ignore: unawaited_futures | ||
| driver.tap(textfield); |
There was a problem hiding this comment.
The driver.tap method returns a Future that completes when the tap command has been processed. By ignoring it, the following Future.delayed might start executing before the tap is effective, which could lead to race conditions or flaky tests. It's safer to await the tap operation.
| // ignore: unawaited_futures | |
| driver.tap(textfield); | |
| await driver.tap(textfield); |
There was a problem hiding this comment.
Ignoring because it seems intentional from the Future.delayed below.
| // ignore: unawaited_futures | ||
| driver?.waitFor(find.byValueKey('PlatformView')); |
There was a problem hiding this comment.
The driver.waitFor method returns a Future. Not awaiting it inside runUnsynchronized can lead to race conditions, as frame syncing might be re-enabled before the waitFor operation is complete. This could make the test flaky. It should be awaited to ensure the unsynchronized block includes the entire waitFor operation.
| // ignore: unawaited_futures | |
| driver?.waitFor(find.byValueKey('PlatformView')); | |
| await driver?.waitFor(find.byValueKey('PlatformView')); |
| dynamic waitForError; | ||
| waitFor(item, timeout: timeout).then<void>( | ||
| (_) { | ||
| isVisible = true; | ||
| }, | ||
| onError: (Object error, StackTrace stack) { | ||
| waitForError = error; | ||
| }, | ||
| ); | ||
|
|
||
| await Future<void>.delayed(const Duration(milliseconds: 500)); | ||
| while (!isVisible) { | ||
| while (!isVisible && waitForError == null) { | ||
| await scroll(scrollable, dxScroll, dyScroll, const Duration(milliseconds: 100)); | ||
| await Future<void>.delayed(const Duration(milliseconds: 500)); | ||
| } | ||
| if (waitForError != null) { | ||
| Error.throwWithStackTrace(waitForError as Object, StackTrace.current); | ||
| } |
There was a problem hiding this comment.
This implementation loses the original stack trace from the waitFor error, which makes debugging harder. It's better to capture the StackTrace from the onError callback and use it when rethrowing the error. Also, using Object? is preferred over dynamic for better type safety.
Object? waitForError;
StackTrace? waitForStack;
waitFor(item, timeout: timeout).then<void>(
(_) {
isVisible = true;
},
onError: (Object error, StackTrace stack) {
waitForError = error;
waitForStack = stack;
},
);
await Future<void>.delayed(const Duration(milliseconds: 500));
while (!isVisible && waitForError == null) {
await scroll(scrollable, dxScroll, dyScroll, const Duration(milliseconds: 100));
await Future<void>.delayed(const Duration(milliseconds: 500));
}
if (waitForError != null) {
Error.throwWithStackTrace(waitForError!, waitForStack!);
}| var errorReported = false; | ||
| try { | ||
| await driver.scrollUntilVisible( | ||
| find.byTooltip('scrollable'), | ||
| find.byTooltip('item'), | ||
| dyScroll: 100, | ||
| timeout: const Duration(milliseconds: 500), | ||
| ); | ||
| } catch (error) { | ||
| if (error is DriverError && error.message.contains('waitFor failed')) { | ||
| errorReported = true; | ||
| } | ||
| } | ||
| expect(errorReported, isTrue, reason: 'Error from waitFor should be reported'); |
There was a problem hiding this comment.
This test can be written more concisely and idiomatically using expectLater with a throwsA matcher. This makes the test's intent clearer and provides better failure messages if an unexpected error occurs.
| var errorReported = false; | |
| try { | |
| await driver.scrollUntilVisible( | |
| find.byTooltip('scrollable'), | |
| find.byTooltip('item'), | |
| dyScroll: 100, | |
| timeout: const Duration(milliseconds: 500), | |
| ); | |
| } catch (error) { | |
| if (error is DriverError && error.message.contains('waitFor failed')) { | |
| errorReported = true; | |
| } | |
| } | |
| expect(errorReported, isTrue, reason: 'Error from waitFor should be reported'); | |
| await expectLater( | |
| driver.scrollUntilVisible( | |
| find.byTooltip('scrollable'), | |
| find.byTooltip('item'), | |
| dyScroll: 100, | |
| timeout: const Duration(milliseconds: 500), | |
| ), | |
| throwsA(isA<DriverError>().having( | |
| (DriverError e) => e.message, | |
| 'message', | |
| contains('waitFor failed'), | |
| )), | |
| ); |
| // ignore: unawaited_futures | ||
| driver.tap(textfield); |
There was a problem hiding this comment.
Ignoring because it seems intentional from the Future.delayed below.
| // ignore: unawaited_futures | ||
| driver.tap(textfield); |
There was a problem hiding this comment.
Ignoring because it seems intentional from the Future.delayed below.
| log.clear(); | ||
| fakeClient.artificialExtensionDelay = Completer<void>().future; | ||
| FakeAsync().run((FakeAsync time) { | ||
| // ignore: unawaited_futures |
There was a problem hiding this comment.
Added ignore (and below) because of time.elapse.
Roll Flutter from 2ec61af30672 to 195ae7b3a122 (36 revisions) flutter/flutter@2ec61af...195ae7b 2026-03-10 mdebbar@google.com [web] Updates to the README (flutter/flutter#176292) 2026-03-10 jason-simmons@users.noreply.github.com [Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR (flutter/flutter#183338) 2026-03-10 jason-simmons@users.noreply.github.com DlDeferredImageGPUImpeller::ImageWrapper texture thread safety improvements (flutter/flutter#183429) 2026-03-10 34465683+rkishan516@users.noreply.github.com refactor: remove material imports from system_context_menu_test, table_test (flutter/flutter#183368) 2026-03-10 34465683+rkishan516@users.noreply.github.com refactor: remove material from baseline_test, slivers_test (flutter/flutter#183367) 2026-03-10 30870216+gaaclarke@users.noreply.github.com Migrated circle sdf to euclidean 2d derivative (flutter/flutter#183184) 2026-03-10 engine-flutter-autoroll@skia.org Roll Packages from c717018 to ee460d6 (2 revisions) (flutter/flutter#183451) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 68f24903b592 to 4b35832cc7ea (1 revision) (flutter/flutter#183449) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 8eda160375ea to 68f24903b592 (1 revision) (flutter/flutter#183444) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from e7b957806202 to 8eda160375ea (2 revisions) (flutter/flutter#183440) 2026-03-10 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from ox-II3wPpa818y78_... to 8C_qfgWgoNhkV0_Mn... (flutter/flutter#183437) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 887df915a95e to e7b957806202 (1 revision) (flutter/flutter#183434) 2026-03-10 brackenavaron@gmail.com Remove material from scrollable_test.dart (flutter/flutter#181429) 2026-03-09 737941+loic-sharma@users.noreply.github.com Update 'a: text input' globs (flutter/flutter#183405) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from 3aa442e0624a to 887df915a95e (7 revisions) (flutter/flutter#183423) 2026-03-09 47866232+chunhtai@users.noreply.github.com Adds geometry dirty nodes (flutter/flutter#180375) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 5b1aa4f8db14 to ebef6c849489 (1 revision) (flutter/flutter#183417) 2026-03-09 Veselblu@yandex.ru Add Alexander Dmitriev to AUTHORS (flutter/flutter#183357) 2026-03-09 katelovett@google.com Update org triage (flutter/flutter#183254) 2026-03-09 8847263+littleGnAl@users.noreply.github.com [Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window (flutter/flutter#182963) 2026-03-09 chingjun@google.com Standardize skia includes. (flutter/flutter#183404) 2026-03-09 116356835+AbdeMohlbi@users.noreply.github.com Add a note to `arcTo` docs about the 2PI drawing angle issue (flutter/flutter#183293) 2026-03-09 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#183411) 2026-03-09 bkonyi@google.com [ Tool ] Fix --print-dtd not working for web targets (flutter/flutter#183171) 2026-03-09 victorsanniay@gmail.com Add await or ignore lint to flutter_driver unawaited callsites (flutter/flutter#183334) 2026-03-09 30870216+gaaclarke@users.noreply.github.com Cleanup MockVulkan when the vulkan instance is destroyed (flutter/flutter#183324) 2026-03-09 52160996+FMorschel@users.noreply.github.com Updates tests commit (flutter/flutter#183301) 2026-03-09 22373191+Hari-07@users.noreply.github.com Implements `ClipRSuperellipse` on backdrop filter on platform view (flutter/flutter#182643) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from ea4fd0e1472a to 3aa442e0624a (1 revision) (flutter/flutter#183397) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 050b2f646425 to 5b1aa4f8db14 (1 revision) (flutter/flutter#183393) 2026-03-09 engine-flutter-autoroll@skia.org Roll Packages from fe3de64 to c717018 (10 revisions) (flutter/flutter#183396) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from a83dca75c531 to ea4fd0e1472a (1 revision) (flutter/flutter#183389) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from 254e44141861 to a83dca75c531 (7 revisions) (flutter/flutter#183388) 2026-03-09 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from giLoee6arX5CRHuRh... to ox-II3wPpa818y78_... (flutter/flutter#183386) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 1604910613c7 to 050b2f646425 (1 revision) (flutter/flutter#183383) 2026-03-08 engine-flutter-autoroll@skia.org Roll Skia from af994ae4d990 to 254e44141861 (2 revisions) (flutter/flutter#183377) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: ...
…er#183334) Part of [Add @awaitNotRequired annotation to flutter sdk](flutter#181513)
…r#11222) Roll Flutter from 2ec61af30672 to 195ae7b3a122 (36 revisions) flutter/flutter@2ec61af...195ae7b 2026-03-10 mdebbar@google.com [web] Updates to the README (flutter/flutter#176292) 2026-03-10 jason-simmons@users.noreply.github.com [Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR (flutter/flutter#183338) 2026-03-10 jason-simmons@users.noreply.github.com DlDeferredImageGPUImpeller::ImageWrapper texture thread safety improvements (flutter/flutter#183429) 2026-03-10 34465683+rkishan516@users.noreply.github.com refactor: remove material imports from system_context_menu_test, table_test (flutter/flutter#183368) 2026-03-10 34465683+rkishan516@users.noreply.github.com refactor: remove material from baseline_test, slivers_test (flutter/flutter#183367) 2026-03-10 30870216+gaaclarke@users.noreply.github.com Migrated circle sdf to euclidean 2d derivative (flutter/flutter#183184) 2026-03-10 engine-flutter-autoroll@skia.org Roll Packages from c717018 to ee460d6 (2 revisions) (flutter/flutter#183451) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 68f24903b592 to 4b35832cc7ea (1 revision) (flutter/flutter#183449) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 8eda160375ea to 68f24903b592 (1 revision) (flutter/flutter#183444) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from e7b957806202 to 8eda160375ea (2 revisions) (flutter/flutter#183440) 2026-03-10 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from ox-II3wPpa818y78_... to 8C_qfgWgoNhkV0_Mn... (flutter/flutter#183437) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 887df915a95e to e7b957806202 (1 revision) (flutter/flutter#183434) 2026-03-10 brackenavaron@gmail.com Remove material from scrollable_test.dart (flutter/flutter#181429) 2026-03-09 737941+loic-sharma@users.noreply.github.com Update 'a: text input' globs (flutter/flutter#183405) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from 3aa442e0624a to 887df915a95e (7 revisions) (flutter/flutter#183423) 2026-03-09 47866232+chunhtai@users.noreply.github.com Adds geometry dirty nodes (flutter/flutter#180375) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 5b1aa4f8db14 to ebef6c849489 (1 revision) (flutter/flutter#183417) 2026-03-09 Veselblu@yandex.ru Add Alexander Dmitriev to AUTHORS (flutter/flutter#183357) 2026-03-09 katelovett@google.com Update org triage (flutter/flutter#183254) 2026-03-09 8847263+littleGnAl@users.noreply.github.com [Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window (flutter/flutter#182963) 2026-03-09 chingjun@google.com Standardize skia includes. (flutter/flutter#183404) 2026-03-09 116356835+AbdeMohlbi@users.noreply.github.com Add a note to `arcTo` docs about the 2PI drawing angle issue (flutter/flutter#183293) 2026-03-09 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#183411) 2026-03-09 bkonyi@google.com [ Tool ] Fix --print-dtd not working for web targets (flutter/flutter#183171) 2026-03-09 victorsanniay@gmail.com Add await or ignore lint to flutter_driver unawaited callsites (flutter/flutter#183334) 2026-03-09 30870216+gaaclarke@users.noreply.github.com Cleanup MockVulkan when the vulkan instance is destroyed (flutter/flutter#183324) 2026-03-09 52160996+FMorschel@users.noreply.github.com Updates tests commit (flutter/flutter#183301) 2026-03-09 22373191+Hari-07@users.noreply.github.com Implements `ClipRSuperellipse` on backdrop filter on platform view (flutter/flutter#182643) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from ea4fd0e1472a to 3aa442e0624a (1 revision) (flutter/flutter#183397) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 050b2f646425 to 5b1aa4f8db14 (1 revision) (flutter/flutter#183393) 2026-03-09 engine-flutter-autoroll@skia.org Roll Packages from fe3de64 to c717018 (10 revisions) (flutter/flutter#183396) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from a83dca75c531 to ea4fd0e1472a (1 revision) (flutter/flutter#183389) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from 254e44141861 to a83dca75c531 (7 revisions) (flutter/flutter#183388) 2026-03-09 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from giLoee6arX5CRHuRh... to ox-II3wPpa818y78_... (flutter/flutter#183386) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 1604910613c7 to 050b2f646425 (1 revision) (flutter/flutter#183383) 2026-03-08 engine-flutter-autoroll@skia.org Roll Skia from af994ae4d990 to 254e44141861 (2 revisions) (flutter/flutter#183377) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: ...
…er#183334) Part of [Add @awaitNotRequired annotation to flutter sdk](flutter#181513)
…er#183334) Part of [Add @awaitNotRequired annotation to flutter sdk](flutter#181513)
…r#11222) Roll Flutter from 2ec61af30672 to 195ae7b3a122 (36 revisions) flutter/flutter@2ec61af...195ae7b 2026-03-10 mdebbar@google.com [web] Updates to the README (flutter/flutter#176292) 2026-03-10 jason-simmons@users.noreply.github.com [Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR (flutter/flutter#183338) 2026-03-10 jason-simmons@users.noreply.github.com DlDeferredImageGPUImpeller::ImageWrapper texture thread safety improvements (flutter/flutter#183429) 2026-03-10 34465683+rkishan516@users.noreply.github.com refactor: remove material imports from system_context_menu_test, table_test (flutter/flutter#183368) 2026-03-10 34465683+rkishan516@users.noreply.github.com refactor: remove material from baseline_test, slivers_test (flutter/flutter#183367) 2026-03-10 30870216+gaaclarke@users.noreply.github.com Migrated circle sdf to euclidean 2d derivative (flutter/flutter#183184) 2026-03-10 engine-flutter-autoroll@skia.org Roll Packages from c717018 to ee460d6 (2 revisions) (flutter/flutter#183451) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 68f24903b592 to 4b35832cc7ea (1 revision) (flutter/flutter#183449) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 8eda160375ea to 68f24903b592 (1 revision) (flutter/flutter#183444) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from e7b957806202 to 8eda160375ea (2 revisions) (flutter/flutter#183440) 2026-03-10 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from ox-II3wPpa818y78_... to 8C_qfgWgoNhkV0_Mn... (flutter/flutter#183437) 2026-03-10 engine-flutter-autoroll@skia.org Roll Skia from 887df915a95e to e7b957806202 (1 revision) (flutter/flutter#183434) 2026-03-10 brackenavaron@gmail.com Remove material from scrollable_test.dart (flutter/flutter#181429) 2026-03-09 737941+loic-sharma@users.noreply.github.com Update 'a: text input' globs (flutter/flutter#183405) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from 3aa442e0624a to 887df915a95e (7 revisions) (flutter/flutter#183423) 2026-03-09 47866232+chunhtai@users.noreply.github.com Adds geometry dirty nodes (flutter/flutter#180375) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 5b1aa4f8db14 to ebef6c849489 (1 revision) (flutter/flutter#183417) 2026-03-09 Veselblu@yandex.ru Add Alexander Dmitriev to AUTHORS (flutter/flutter#183357) 2026-03-09 katelovett@google.com Update org triage (flutter/flutter#183254) 2026-03-09 8847263+littleGnAl@users.noreply.github.com [Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window (flutter/flutter#182963) 2026-03-09 chingjun@google.com Standardize skia includes. (flutter/flutter#183404) 2026-03-09 116356835+AbdeMohlbi@users.noreply.github.com Add a note to `arcTo` docs about the 2PI drawing angle issue (flutter/flutter#183293) 2026-03-09 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#183411) 2026-03-09 bkonyi@google.com [ Tool ] Fix --print-dtd not working for web targets (flutter/flutter#183171) 2026-03-09 victorsanniay@gmail.com Add await or ignore lint to flutter_driver unawaited callsites (flutter/flutter#183334) 2026-03-09 30870216+gaaclarke@users.noreply.github.com Cleanup MockVulkan when the vulkan instance is destroyed (flutter/flutter#183324) 2026-03-09 52160996+FMorschel@users.noreply.github.com Updates tests commit (flutter/flutter#183301) 2026-03-09 22373191+Hari-07@users.noreply.github.com Implements `ClipRSuperellipse` on backdrop filter on platform view (flutter/flutter#182643) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from ea4fd0e1472a to 3aa442e0624a (1 revision) (flutter/flutter#183397) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 050b2f646425 to 5b1aa4f8db14 (1 revision) (flutter/flutter#183393) 2026-03-09 engine-flutter-autoroll@skia.org Roll Packages from fe3de64 to c717018 (10 revisions) (flutter/flutter#183396) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from a83dca75c531 to ea4fd0e1472a (1 revision) (flutter/flutter#183389) 2026-03-09 engine-flutter-autoroll@skia.org Roll Skia from 254e44141861 to a83dca75c531 (7 revisions) (flutter/flutter#183388) 2026-03-09 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from giLoee6arX5CRHuRh... to ox-II3wPpa818y78_... (flutter/flutter#183386) 2026-03-09 engine-flutter-autoroll@skia.org Roll Dart SDK from 1604910613c7 to 050b2f646425 (1 revision) (flutter/flutter#183383) 2026-03-08 engine-flutter-autoroll@skia.org Roll Skia from af994ae4d990 to 254e44141861 (2 revisions) (flutter/flutter#183377) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: ...
Part of Add @awaitNotRequired annotation to flutter sdk