From b329c0f49df5f4fc202f1ea13ef9797b5cc17def Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 22 May 2023 11:11:47 -0400 Subject: [PATCH 01/17] Enable by default --- analysis_options.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 3c924bb88a3..f329d6f31b1 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -183,7 +183,7 @@ linter: - tighten_type_of_initializing_formals # - type_annotate_public_apis # subset of always_specify_types - type_init_formals - # - unawaited_futures # too many false positives, especially with the way AnimationController works + - unawaited_futures # DIFFERENT FROM FLUTTER/FLUTTER: Off there for too many false positives; not an issue here, and has been a source of bugs in the past. - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_const From f2095ffc4e1ce9dba61cc7e2f67e5ba7cd44087a Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 13:20:10 -0400 Subject: [PATCH 02/17] Add the new opt-outs --- packages/animations/analysis_options.yaml | 10 ++++++++++ .../camera_android_camerax/analysis_options.yaml | 8 ++++++++ packages/go_router/analysis_options.yaml | 10 ++++++++++ .../webview_flutter/analysis_options.yaml | 8 ++++++++ .../webview_flutter_android/analysis_options.yaml | 8 ++++++++ .../analysis_options.yaml | 8 ++++++++ script/configs/custom_analysis.yaml | 14 ++++++++++++-- 7 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 packages/animations/analysis_options.yaml create mode 100644 packages/camera/camera_android_camerax/analysis_options.yaml create mode 100644 packages/webview_flutter/webview_flutter/analysis_options.yaml create mode 100644 packages/webview_flutter/webview_flutter_android/analysis_options.yaml create mode 100644 packages/webview_flutter/webview_flutter_wkwebview/analysis_options.yaml diff --git a/packages/animations/analysis_options.yaml b/packages/animations/analysis_options.yaml new file mode 100644 index 00000000000..2b795b9100c --- /dev/null +++ b/packages/animations/analysis_options.yaml @@ -0,0 +1,10 @@ +# This custom rule set only exists to allow opting out of the repository +# default of enabling unawaited_futures. Please do NOT add more changes +# here without consulting with #hackers-ecosystem on Discord. + +include: ../../analysis_options.yaml + +linter: + rules: + # Matches flutter/flutter, which disables this rule due to false positives. + unawaited_futures: false diff --git a/packages/camera/camera_android_camerax/analysis_options.yaml b/packages/camera/camera_android_camerax/analysis_options.yaml new file mode 100644 index 00000000000..7c19fabd68d --- /dev/null +++ b/packages/camera/camera_android_camerax/analysis_options.yaml @@ -0,0 +1,8 @@ +# TODO(stuartmorgan): Remove this file and fix all the unawaited_futures +# violations. See https://github.com/flutter/flutter/issues/127323 + +include: ../../../analysis_options.yaml + +linter: + rules: + unawaited_futures: false diff --git a/packages/go_router/analysis_options.yaml b/packages/go_router/analysis_options.yaml index cfb845a14d7..1818d64f9c4 100644 --- a/packages/go_router/analysis_options.yaml +++ b/packages/go_router/analysis_options.yaml @@ -1,5 +1,15 @@ +# This custom rule set only exists to allow very targeted changes +# relative to the default repo settings, for specific use cases. +# Please do NOT add more changes here without consulting with +# #hackers-ecosystem on Discord. + include: ../../analysis_options.yaml analyzer: exclude: + # This directory deliberately has errors, to test `fix`. - "test_fixes/**" +linter: + rules: + # Matches flutter/flutter, which disables this rule due to false positives. + unawaited_futures: false diff --git a/packages/webview_flutter/webview_flutter/analysis_options.yaml b/packages/webview_flutter/webview_flutter/analysis_options.yaml new file mode 100644 index 00000000000..7c19fabd68d --- /dev/null +++ b/packages/webview_flutter/webview_flutter/analysis_options.yaml @@ -0,0 +1,8 @@ +# TODO(stuartmorgan): Remove this file and fix all the unawaited_futures +# violations. See https://github.com/flutter/flutter/issues/127323 + +include: ../../../analysis_options.yaml + +linter: + rules: + unawaited_futures: false diff --git a/packages/webview_flutter/webview_flutter_android/analysis_options.yaml b/packages/webview_flutter/webview_flutter_android/analysis_options.yaml new file mode 100644 index 00000000000..7c19fabd68d --- /dev/null +++ b/packages/webview_flutter/webview_flutter_android/analysis_options.yaml @@ -0,0 +1,8 @@ +# TODO(stuartmorgan): Remove this file and fix all the unawaited_futures +# violations. See https://github.com/flutter/flutter/issues/127323 + +include: ../../../analysis_options.yaml + +linter: + rules: + unawaited_futures: false diff --git a/packages/webview_flutter/webview_flutter_wkwebview/analysis_options.yaml b/packages/webview_flutter/webview_flutter_wkwebview/analysis_options.yaml new file mode 100644 index 00000000000..7c19fabd68d --- /dev/null +++ b/packages/webview_flutter/webview_flutter_wkwebview/analysis_options.yaml @@ -0,0 +1,8 @@ +# TODO(stuartmorgan): Remove this file and fix all the unawaited_futures +# violations. See https://github.com/flutter/flutter/issues/127323 + +include: ../../../analysis_options.yaml + +linter: + rules: + unawaited_futures: false diff --git a/script/configs/custom_analysis.yaml b/script/configs/custom_analysis.yaml index 569f9e1208d..f75447d9eea 100644 --- a/script/configs/custom_analysis.yaml +++ b/script/configs/custom_analysis.yaml @@ -11,11 +11,23 @@ # which references this file from source, but out-of-repo. # Contact stuartmorgan or devoncarew for assistance if necessary. +# Temporary opt-outs of unawaited_futures; see +# https://github.com/flutter/flutter/issues/127323 +- camera_android_camerax +- webview_flutter/webview_flutter +- webview_flutter_android +- webview_flutter_wkwebview +# Opts out of unawaited_futures, matching flutter/flutter's disabling due +# to interactions with animation. +- animations # Deliberately uses flutter_lints, as that's what it is demonstrating. - flutter_lints/example # Adopts some flutter_tools rules regarding public api docs due to being an # extension of the tool and using tools base code. - flutter_migrate +# Has some test files that are intentionally broken to conduct dart fix tests. +# Also opts out of unawaited_futures, matching flutter/flutter. +- go_router # Adds unawaited_futures. We should investigating adding this to the root # options instead. - metrics_center @@ -23,5 +35,3 @@ - rfw/example # Disables docs requirements, as it is test code. - web_benchmarks/testing/test_app -# Has some test files that are intentionally broken to conduct dart fix tests. -- go_router From 907d834abdc8ee80cbd2078ad7e1df66afa98c43 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 13:24:20 -0400 Subject: [PATCH 03/17] Remove metrics center --- packages/metrics_center/analysis_options.yaml | 5 ----- script/configs/custom_analysis.yaml | 3 --- 2 files changed, 8 deletions(-) delete mode 100644 packages/metrics_center/analysis_options.yaml diff --git a/packages/metrics_center/analysis_options.yaml b/packages/metrics_center/analysis_options.yaml deleted file mode 100644 index 1abfc01e782..00000000000 --- a/packages/metrics_center/analysis_options.yaml +++ /dev/null @@ -1,5 +0,0 @@ -include: ../../analysis_options.yaml - -linter: - rules: - unawaited_futures: true diff --git a/script/configs/custom_analysis.yaml b/script/configs/custom_analysis.yaml index f75447d9eea..2ed92c4a7d3 100644 --- a/script/configs/custom_analysis.yaml +++ b/script/configs/custom_analysis.yaml @@ -28,9 +28,6 @@ # Has some test files that are intentionally broken to conduct dart fix tests. # Also opts out of unawaited_futures, matching flutter/flutter. - go_router -# Adds unawaited_futures. We should investigating adding this to the root -# options instead. -- metrics_center # Has some constructions that are currently handled poorly by dart format. - rfw/example # Disables docs requirements, as it is test code. From 87051f650e5fe632e5b5c2b4e85e3088b37d095b Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 14:07:03 -0400 Subject: [PATCH 04/17] Fix format --- script/configs/custom_analysis.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/configs/custom_analysis.yaml b/script/configs/custom_analysis.yaml index 2ed92c4a7d3..1e6d9bd9f00 100644 --- a/script/configs/custom_analysis.yaml +++ b/script/configs/custom_analysis.yaml @@ -13,10 +13,10 @@ # Temporary opt-outs of unawaited_futures; see # https://github.com/flutter/flutter/issues/127323 -- camera_android_camerax +- camera/camera_android_camerax - webview_flutter/webview_flutter -- webview_flutter_android -- webview_flutter_wkwebview +- webview_flutter/webview_flutter_android +- webview_flutter/webview_flutter_wkwebview # Opts out of unawaited_futures, matching flutter/flutter's disabling due # to interactions with animation. - animations From a8c76516dd96aa59367ec2413808454b0c13ac14 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 15:02:49 -0400 Subject: [PATCH 05/17] Fix url_launcher tests --- .../url_launcher_ios/test/url_launcher_ios_test.dart | 4 ++-- .../url_launcher_macos/test/url_launcher_macos_test.dart | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/url_launcher/url_launcher_ios/test/url_launcher_ios_test.dart b/packages/url_launcher/url_launcher_ios/test/url_launcher_ios_test.dart index f87859e3fc4..9274173f90b 100644 --- a/packages/url_launcher/url_launcher_ios/test/url_launcher_ios_test.dart +++ b/packages/url_launcher/url_launcher_ios/test/url_launcher_ios_test.dart @@ -36,7 +36,7 @@ void main() { test('canLaunch invalid URL passes the PlatformException through', () async { final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); - expectLater(launcher.canLaunch('invalid://u r l'), + await expectLater(launcher.canLaunch('invalid://u r l'), throwsA(isA())); }); @@ -74,7 +74,7 @@ void main() { test('launch invalid URL passes the PlatformException through', () async { final UrlLauncherIOS launcher = UrlLauncherIOS(api: api); - expectLater( + await expectLater( launcher.launch( 'invalid://u r l', useSafariVC: false, diff --git a/packages/url_launcher/url_launcher_macos/test/url_launcher_macos_test.dart b/packages/url_launcher/url_launcher_macos/test/url_launcher_macos_test.dart index 35931860ae9..a7147af7749 100644 --- a/packages/url_launcher/url_launcher_macos/test/url_launcher_macos_test.dart +++ b/packages/url_launcher/url_launcher_macos/test/url_launcher_macos_test.dart @@ -34,13 +34,13 @@ void main() { test('invalid URL returns a PlatformException', () async { final UrlLauncherMacOS launcher = UrlLauncherMacOS(api: api); - expectLater(launcher.canLaunch('invalid://u r l'), + await expectLater(launcher.canLaunch('invalid://u r l'), throwsA(isA())); }); test('passes unexpected PlatformExceptions through', () async { final UrlLauncherMacOS launcher = UrlLauncherMacOS(api: api); - expectLater(launcher.canLaunch('unexpectedthrow://someexception'), + await expectLater(launcher.canLaunch('unexpectedthrow://someexception'), throwsA(isA())); }); }); @@ -78,7 +78,7 @@ void main() { test('invalid URL returns a PlatformException', () async { final UrlLauncherMacOS launcher = UrlLauncherMacOS(api: api); - expectLater( + await expectLater( launcher.launch( 'invalid://u r l', useSafariVC: false, @@ -93,7 +93,7 @@ void main() { test('passes unexpected PlatformExceptions through', () async { final UrlLauncherMacOS launcher = UrlLauncherMacOS(api: api); - expectLater( + await expectLater( launcher.launch( 'unexpectedthrow://someexception', useSafariVC: false, From 8e6981e318d7ac469f687459dc1da6ac7cfb1e16 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 15:05:04 -0400 Subject: [PATCH 06/17] Fix camera tests --- packages/camera/camera/test/camera_image_stream_test.dart | 4 ++-- packages/camera/camera_android/test/android_camera_test.dart | 4 ++-- .../camera_avfoundation/test/avfoundation_camera_test.dart | 4 ++-- .../test/method_channel/method_channel_camera_test.dart | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/camera/camera/test/camera_image_stream_test.dart b/packages/camera/camera/test/camera_image_stream_test.dart index 29b5cceaa49..4fe46503051 100644 --- a/packages/camera/camera/test/camera_image_stream_test.dart +++ b/packages/camera/camera/test/camera_image_stream_test.dart @@ -174,7 +174,7 @@ void main() { await cameraController.initialize(); - cameraController.startVideoRecording( + await cameraController.startVideoRecording( onAvailable: (CameraImage image) => null); expect( @@ -192,7 +192,7 @@ void main() { await cameraController.initialize(); - cameraController.startVideoRecording(); + await cameraController.startVideoRecording(); expect(mockPlatform.streamCallLog.contains('startVideoCapturing'), isTrue); }); diff --git a/packages/camera/camera_android/test/android_camera_test.dart b/packages/camera/camera_android/test/android_camera_test.dart index b56aa4e352a..8c811403304 100644 --- a/packages/camera/camera_android/test/android_camera_test.dart +++ b/packages/camera/camera_android/test/android_camera_test.dart @@ -1119,7 +1119,7 @@ void main() { isMethodCall('startImageStream', arguments: null), ]); - subscription.cancel(); + await subscription.cancel(); }); test('Should stop streaming', () async { @@ -1136,7 +1136,7 @@ void main() { final StreamSubscription subscription = camera .onStreamedFrameAvailable(cameraId) .listen((CameraImageData imageData) {}); - subscription.cancel(); + await subscription.cancel(); // Assert expect(channel.log, [ diff --git a/packages/camera/camera_avfoundation/test/avfoundation_camera_test.dart b/packages/camera/camera_avfoundation/test/avfoundation_camera_test.dart index e756f38ff12..17b06cddc1a 100644 --- a/packages/camera/camera_avfoundation/test/avfoundation_camera_test.dart +++ b/packages/camera/camera_avfoundation/test/avfoundation_camera_test.dart @@ -1120,7 +1120,7 @@ void main() { isMethodCall('startImageStream', arguments: null), ]); - subscription.cancel(); + await subscription.cancel(); }); test('Should stop streaming', () async { @@ -1137,7 +1137,7 @@ void main() { final StreamSubscription subscription = camera .onStreamedFrameAvailable(cameraId) .listen((CameraImageData imageData) {}); - subscription.cancel(); + await subscription.cancel(); // Assert expect(channel.log, [ diff --git a/packages/camera/camera_platform_interface/test/method_channel/method_channel_camera_test.dart b/packages/camera/camera_platform_interface/test/method_channel/method_channel_camera_test.dart index b01123d7cb2..1fd6445e746 100644 --- a/packages/camera/camera_platform_interface/test/method_channel/method_channel_camera_test.dart +++ b/packages/camera/camera_platform_interface/test/method_channel/method_channel_camera_test.dart @@ -1085,7 +1085,7 @@ void main() { isMethodCall('startImageStream', arguments: null), ]); - subscription.cancel(); + await subscription.cancel(); }); test('Should stop streaming', () async { @@ -1102,7 +1102,7 @@ void main() { final StreamSubscription subscription = camera .onStreamedFrameAvailable(cameraId) .listen((CameraImageData imageData) {}); - subscription.cancel(); + await subscription.cancel(); // Assert expect(channel.log, [ From 055260b9d7f112ab7e96afec6561d6f20179bcda Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 15:22:19 -0400 Subject: [PATCH 07/17] Fix script --- script/tool/lib/src/common/package_looping_command.dart | 2 +- script/tool/lib/src/make_deps_path_based_command.dart | 3 ++- script/tool/test/publish_check_command_test.dart | 4 ++-- script/tool/test/readme_check_command_test.dart | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/script/tool/lib/src/common/package_looping_command.dart b/script/tool/lib/src/common/package_looping_command.dart index ccfeea0e473..5462f5378c7 100644 --- a/script/tool/lib/src/common/package_looping_command.dart +++ b/script/tool/lib/src/common/package_looping_command.dart @@ -324,7 +324,7 @@ abstract class PackageLoopingCommand extends PackageCommand { } _currentPackageEntry = null; - completeRun(); + await completeRun(); print('\n'); // If there were any errors reported, summarize them and exit. diff --git a/script/tool/lib/src/make_deps_path_based_command.dart b/script/tool/lib/src/make_deps_path_based_command.dart index 93953871fdb..8884a3deddc 100644 --- a/script/tool/lib/src/make_deps_path_based_command.dart +++ b/script/tool/lib/src/make_deps_path_based_command.dart @@ -249,7 +249,8 @@ $dependencyOverridesKey: // example app doesn't. Since integration tests are run in the example app, // it needs the overrides in order for tests to pass. for (final RepositoryPackage example in package.getExamples()) { - _addDependencyOverridesIfNecessary(example, localDependencies, versions, + await _addDependencyOverridesIfNecessary( + example, localDependencies, versions, additionalPackagesToOverride: packagesToOverride); } diff --git a/script/tool/test/publish_check_command_test.dart b/script/tool/test/publish_check_command_test.dart index b85e56064c9..5cdbf9ae926 100644 --- a/script/tool/test/publish_check_command_test.dart +++ b/script/tool/test/publish_check_command_test.dart @@ -159,7 +159,7 @@ void main() { test('fails if AUTHORS is missing', () async { final RepositoryPackage package = createFakePackage('a_package', packagesDir); - package.authorsFile.delete(); + package.authorsFile.deleteSync(); Error? commandError; final List output = await runCapturingPrint( @@ -183,7 +183,7 @@ void main() { packagesDir.parent .childDirectory('third_party') .childDirectory('packages')); - package.authorsFile.delete(); + package.authorsFile.deleteSync(); final List output = await runCapturingPrint(runner, ['publish-check']); diff --git a/script/tool/test/readme_check_command_test.dart b/script/tool/test/readme_check_command_test.dart index eb2b6c8e751..938ea77e455 100644 --- a/script/tool/test/readme_check_command_test.dart +++ b/script/tool/test/readme_check_command_test.dart @@ -100,7 +100,7 @@ void main() { const String subpackageName = 'special_test'; final RepositoryPackage miscSubpackage = createFakePackage(subpackageName, package.directory); - miscSubpackage.readmeFile.delete(); + miscSubpackage.readmeFile.deleteSync(); final List output = await runCapturingPrint(runner, ['readme-check']); From d6cb450a39961e9b2020ba88f03ee9fbde3e7fbe Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 15:49:44 -0400 Subject: [PATCH 08/17] Fix violations --- .../camera/lib/src/camera_controller.dart | 2 +- .../example/lib/camera_controller.dart | 6 +++--- .../example/lib/camera_controller.dart | 6 +++--- .../camera_windows/example/lib/main.dart | 8 +++---- packages/cross_file/tool/run_tests.dart | 5 +++-- packages/flutter_image/lib/network.dart | 2 +- .../lib/demos/basic_markdown_demo.dart | 6 ++++-- .../example/lib/screens/demo_screen.dart | 2 +- .../go_router_builder/example/lib/main.dart | 6 ++++-- .../test/js_loader_test.dart | 2 +- .../tool/run_tests.dart | 5 +++-- .../example/lib/readme_sample.dart | 2 +- .../lib/src/google_map.dart | 20 +++++++----------- .../example/lib/example_google_map.dart | 14 ++++++------- .../lib/example_google_map.dart | 14 ++++++------- .../google_sign_in/example/lib/main.dart | 4 ++-- .../google_sign_in/lib/google_sign_in.dart | 13 ++++++------ .../lib/google_sign_in_web.dart | 6 +++--- .../lib/src/gis_client.dart | 4 ++-- .../in_app_purchase/example/lib/main.dart | 2 +- .../example/lib/main.dart | 2 +- .../billing_client_manager_test.dart | 10 ++++----- .../test/palette_generator_test.dart | 2 +- .../test/null_safe_test.dart | 8 +++---- .../pigeon/tool/shared/process_utils.dart | 6 ++++-- .../shared_preferences_test.dart | 8 +++---- packages/web_benchmarks/lib/src/runner.dart | 6 +++--- .../webview_flutter_test.dart | 21 ++++++++++--------- 28 files changed, 97 insertions(+), 95 deletions(-) diff --git a/packages/camera/camera/lib/src/camera_controller.dart b/packages/camera/camera/lib/src/camera_controller.dart index 69917d3f039..c907980b268 100644 --- a/packages/camera/camera/lib/src/camera_controller.dart +++ b/packages/camera/camera/lib/src/camera_controller.dart @@ -552,7 +552,7 @@ class CameraController extends ValueNotifier { } if (value.isStreamingImages) { - stopImageStream(); + await stopImageStream(); } try { diff --git a/packages/camera/camera_android/example/lib/camera_controller.dart b/packages/camera/camera_android/example/lib/camera_controller.dart index fd4f09a027b..9ab06140170 100644 --- a/packages/camera/camera_android/example/lib/camera_controller.dart +++ b/packages/camera/camera_android/example/lib/camera_controller.dart @@ -229,12 +229,12 @@ class CameraController extends ValueNotifier { enableAudio: enableAudio, ); - CameraPlatform.instance + unawaited(CameraPlatform.instance .onCameraInitialized(_cameraId) .first .then((CameraInitializedEvent event) { initializeCompleter.complete(event); - }); + })); await CameraPlatform.instance.initializeCamera( _cameraId, @@ -444,8 +444,8 @@ class CameraController extends ValueNotifier { if (_isDisposed) { return; } - _deviceOrientationSubscription?.cancel(); _isDisposed = true; + await _deviceOrientationSubscription?.cancel(); super.dispose(); if (_initCalled != null) { await _initCalled; diff --git a/packages/camera/camera_avfoundation/example/lib/camera_controller.dart b/packages/camera/camera_avfoundation/example/lib/camera_controller.dart index 6e1804328d5..36b9ac68cfd 100644 --- a/packages/camera/camera_avfoundation/example/lib/camera_controller.dart +++ b/packages/camera/camera_avfoundation/example/lib/camera_controller.dart @@ -229,12 +229,12 @@ class CameraController extends ValueNotifier { enableAudio: enableAudio, ); - CameraPlatform.instance + unawaited(CameraPlatform.instance .onCameraInitialized(_cameraId) .first .then((CameraInitializedEvent event) { initializeCompleter.complete(event); - }); + })); await CameraPlatform.instance.initializeCamera( _cameraId, @@ -443,8 +443,8 @@ class CameraController extends ValueNotifier { if (_isDisposed) { return; } - _deviceOrientationSubscription?.cancel(); _isDisposed = true; + await _deviceOrientationSubscription?.cancel(); super.dispose(); if (_initCalled != null) { await _initCalled; diff --git a/packages/camera/camera_windows/example/lib/main.dart b/packages/camera/camera_windows/example/lib/main.dart index e6d903c774b..5d5deac5e85 100644 --- a/packages/camera/camera_windows/example/lib/main.dart +++ b/packages/camera/camera_windows/example/lib/main.dart @@ -99,12 +99,12 @@ class _MyAppState extends State { enableAudio: _recordAudio, ); - _errorStreamSubscription?.cancel(); + unawaited(_errorStreamSubscription?.cancel()); _errorStreamSubscription = CameraPlatform.instance .onCameraError(cameraId) .listen(_onCameraError); - _cameraClosingStreamSubscription?.cancel(); + unawaited(_cameraClosingStreamSubscription?.cancel()); _cameraClosingStreamSubscription = CameraPlatform.instance .onCameraClosing(cameraId) .listen(_onCameraClosing); @@ -193,7 +193,7 @@ class _MyAppState extends State { Future _recordTimed(int seconds) async { if (_initialized && _cameraId > 0 && !_recordingTimed) { - CameraPlatform.instance + unawaited(CameraPlatform.instance .onVideoRecordedEvent(_cameraId) .first .then((VideoRecordedEvent event) async { @@ -204,7 +204,7 @@ class _MyAppState extends State { _showInSnackBar('Video captured to: ${event.file.path}'); } - }); + })); await CameraPlatform.instance.startVideoRecording( _cameraId, diff --git a/packages/cross_file/tool/run_tests.dart b/packages/cross_file/tool/run_tests.dart index ef094ef1936..9d569b52110 100644 --- a/packages/cross_file/tool/run_tests.dart +++ b/packages/cross_file/tool/run_tests.dart @@ -8,6 +8,7 @@ // // usage: dart run tool/run_tests.dart // (needs a `chrome` executable in $PATH, or a tweak to dart_test.yaml) +import 'dart:async'; import 'dart:io'; import 'package:path/path.dart' as p; @@ -30,8 +31,8 @@ Future main(List args) async { Future _streamOutput(Future processFuture) async { final Process process = await processFuture; - stdout.addStream(process.stdout); - stderr.addStream(process.stderr); + unawaited(stdout.addStream(process.stdout)); + unawaited(stderr.addStream(process.stderr)); return process; } diff --git a/packages/flutter_image/lib/network.dart b/packages/flutter_image/lib/network.dart index 841d9adf836..e9ae3f05bc6 100644 --- a/packages/flutter_image/lib/network.dart +++ b/packages/flutter_image/lib/network.dart @@ -191,7 +191,7 @@ class NetworkImageWithRetry extends ImageProvider { scale: key.scale, ); } catch (error) { - request?.close(); + await request?.close(); lastFailure = error is FetchFailure ? error : FetchFailure._( diff --git a/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart b/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart index 8c25984bed9..2f8da033249 100644 --- a/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart +++ b/packages/flutter_markdown/example/lib/demos/basic_markdown_demo.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -125,11 +127,11 @@ class _BasicMarkdownDemoState extends State { String? href, String title, ) async { - showDialog( + unawaited(showDialog( context: context, builder: (BuildContext context) => _createDialog(context, text, href, title), - ); + )); } Widget _createDialog( diff --git a/packages/flutter_markdown/example/lib/screens/demo_screen.dart b/packages/flutter_markdown/example/lib/screens/demo_screen.dart index 1acd8c16ae2..6340965e50f 100644 --- a/packages/flutter_markdown/example/lib/screens/demo_screen.dart +++ b/packages/flutter_markdown/example/lib/screens/demo_screen.dart @@ -109,7 +109,7 @@ class DemoNotesView extends StatelessWidget { String? href, String title, ) async { - showDialog( + await showDialog( context: context, builder: (BuildContext context) => _createDialog(context, text, href, title), diff --git a/packages/go_router_builder/example/lib/main.dart b/packages/go_router_builder/example/lib/main.dart index a8ff9ad5b6f..4c90452394b 100644 --- a/packages/go_router_builder/example/lib/main.dart +++ b/packages/go_router_builder/example/lib/main.dart @@ -4,6 +4,8 @@ // ignore_for_file: public_member_api_docs +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:provider/provider.dart'; @@ -185,7 +187,7 @@ class HomeScreen extends StatelessWidget { value: '2', child: const Text('Push w/ return value'), onTap: () async { - FamilyCountRoute(familyData.length) + unawaited(FamilyCountRoute(familyData.length) .push(context) .then((int? value) { if (value != null) { @@ -195,7 +197,7 @@ class HomeScreen extends StatelessWidget { ), ); } - }); + })); }, ), PopupMenuItem( diff --git a/packages/google_identity_services_web/test/js_loader_test.dart b/packages/google_identity_services_web/test/js_loader_test.dart index a9d857b1eab..44809f1aba2 100644 --- a/packages/google_identity_services_web/test/js_loader_test.dart +++ b/packages/google_identity_services_web/test/js_loader_test.dart @@ -27,7 +27,7 @@ void main() { final dom.DomHtmlElement target = dom.document.createElement('div'); test('Injects script into desired target', () async { - loadWebSdk(target: target); + await loadWebSdk(target: target); // Target now should have a child that is a script element final Object children = js_util.getProperty(target, 'children'); diff --git a/packages/google_identity_services_web/tool/run_tests.dart b/packages/google_identity_services_web/tool/run_tests.dart index 1997e460fc0..552cd8d00e3 100644 --- a/packages/google_identity_services_web/tool/run_tests.dart +++ b/packages/google_identity_services_web/tool/run_tests.dart @@ -8,6 +8,7 @@ // // usage: dart run tool/run_tests.dart // (needs a `chrome` executable in $PATH, or a tweak to dart_test.yaml) +import 'dart:async'; import 'dart:io'; import 'package:path/path.dart' as p; @@ -30,8 +31,8 @@ Future main(List args) async { Future _streamOutput(Future processFuture) async { final Process process = await processFuture; - stdout.addStream(process.stdout); - stderr.addStream(process.stderr); + unawaited(stdout.addStream(process.stdout)); + unawaited(stderr.addStream(process.stderr)); return process; } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart index 528ce6401f1..672a3718776 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart @@ -66,7 +66,7 @@ class MapSampleState extends State { Future _goToTheLake() async { final GoogleMapController controller = await _controller.future; - controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); + await controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); } } // #enddocregion MapSample diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart index a081eab7585..e1b710c307a 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart @@ -360,47 +360,41 @@ class _GoogleMapState extends State { return; } final GoogleMapController controller = await _controller.future; - // ignore: unawaited_futures - controller._updateMapConfiguration(updates); + await controller._updateMapConfiguration(updates); _mapConfiguration = newConfig; } Future _updateMarkers() async { final GoogleMapController controller = await _controller.future; - // ignore: unawaited_futures - controller._updateMarkers( + await controller._updateMarkers( MarkerUpdates.from(_markers.values.toSet(), widget.markers)); _markers = keyByMarkerId(widget.markers); } Future _updatePolygons() async { final GoogleMapController controller = await _controller.future; - // ignore: unawaited_futures - controller._updatePolygons( + await controller._updatePolygons( PolygonUpdates.from(_polygons.values.toSet(), widget.polygons)); _polygons = keyByPolygonId(widget.polygons); } Future _updatePolylines() async { final GoogleMapController controller = await _controller.future; - // ignore: unawaited_futures - controller._updatePolylines( + await controller._updatePolylines( PolylineUpdates.from(_polylines.values.toSet(), widget.polylines)); _polylines = keyByPolylineId(widget.polylines); } Future _updateCircles() async { final GoogleMapController controller = await _controller.future; - // ignore: unawaited_futures - controller._updateCircles( + await controller._updateCircles( CircleUpdates.from(_circles.values.toSet(), widget.circles)); _circles = keyByCircleId(widget.circles); } Future _updateTileOverlays() async { final GoogleMapController controller = await _controller.future; - // ignore: unawaited_futures - controller._updateTileOverlays(widget.tileOverlays); + await controller._updateTileOverlays(widget.tileOverlays); } Future onPlatformViewCreated(int id) async { @@ -410,7 +404,7 @@ class _GoogleMapState extends State { this, ); _controller.complete(controller); - _updateTileOverlays(); + unawaited(_updateTileOverlays()); final MapCreatedCallback? onMapCreated = widget.onMapCreated; if (onMapCreated != null) { onMapCreated(controller); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart index e0817a55f28..c9860ce3431 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart @@ -423,41 +423,41 @@ class _ExampleGoogleMapState extends State { return; } final ExampleGoogleMapController controller = await _controller.future; - controller._updateMapConfiguration(updates); + await controller._updateMapConfiguration(updates); _mapConfiguration = newConfig; } Future _updateMarkers() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updateMarkers( + await controller._updateMarkers( MarkerUpdates.from(_markers.values.toSet(), widget.markers)); _markers = keyByMarkerId(widget.markers); } Future _updatePolygons() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updatePolygons( + await controller._updatePolygons( PolygonUpdates.from(_polygons.values.toSet(), widget.polygons)); _polygons = keyByPolygonId(widget.polygons); } Future _updatePolylines() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updatePolylines( + await controller._updatePolylines( PolylineUpdates.from(_polylines.values.toSet(), widget.polylines)); _polylines = keyByPolylineId(widget.polylines); } Future _updateCircles() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updateCircles( + await controller._updateCircles( CircleUpdates.from(_circles.values.toSet(), widget.circles)); _circles = keyByCircleId(widget.circles); } Future _updateTileOverlays() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updateTileOverlays(widget.tileOverlays); + await controller._updateTileOverlays(widget.tileOverlays); } Future onPlatformViewCreated(int id) async { @@ -468,7 +468,7 @@ class _ExampleGoogleMapState extends State { this, ); _controller.complete(controller); - _updateTileOverlays(); + unawaited(_updateTileOverlays()); widget.onMapCreated?.call(controller); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart index e0817a55f28..c9860ce3431 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart @@ -423,41 +423,41 @@ class _ExampleGoogleMapState extends State { return; } final ExampleGoogleMapController controller = await _controller.future; - controller._updateMapConfiguration(updates); + await controller._updateMapConfiguration(updates); _mapConfiguration = newConfig; } Future _updateMarkers() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updateMarkers( + await controller._updateMarkers( MarkerUpdates.from(_markers.values.toSet(), widget.markers)); _markers = keyByMarkerId(widget.markers); } Future _updatePolygons() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updatePolygons( + await controller._updatePolygons( PolygonUpdates.from(_polygons.values.toSet(), widget.polygons)); _polygons = keyByPolygonId(widget.polygons); } Future _updatePolylines() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updatePolylines( + await controller._updatePolylines( PolylineUpdates.from(_polylines.values.toSet(), widget.polylines)); _polylines = keyByPolylineId(widget.polylines); } Future _updateCircles() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updateCircles( + await controller._updateCircles( CircleUpdates.from(_circles.values.toSet(), widget.circles)); _circles = keyByCircleId(widget.circles); } Future _updateTileOverlays() async { final ExampleGoogleMapController controller = await _controller.future; - controller._updateTileOverlays(widget.tileOverlays); + await controller._updateTileOverlays(widget.tileOverlays); } Future onPlatformViewCreated(int id) async { @@ -468,7 +468,7 @@ class _ExampleGoogleMapState extends State { this, ); _controller.complete(controller); - _updateTileOverlays(); + unawaited(_updateTileOverlays()); widget.onMapCreated?.call(controller); } diff --git a/packages/google_sign_in/google_sign_in/example/lib/main.dart b/packages/google_sign_in/google_sign_in/example/lib/main.dart index abb587ccdf8..a103353c797 100644 --- a/packages/google_sign_in/google_sign_in/example/lib/main.dart +++ b/packages/google_sign_in/google_sign_in/example/lib/main.dart @@ -70,7 +70,7 @@ class _SignInDemoState extends State { // Now that we know that the user can access the required scopes, the app // can call the REST API. if (isAuthorized) { - _handleGetContact(account!); + unawaited(_handleGetContact(account!)); } }); @@ -156,7 +156,7 @@ class _SignInDemoState extends State { _isAuthorized = isAuthorized; }); if (isAuthorized) { - _handleGetContact(_currentUser!); + unawaited(_handleGetContact(_currentUser!)); } } diff --git a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart index 4af1229882c..8068181f842 100644 --- a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart +++ b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart @@ -296,11 +296,10 @@ class GoogleSignIn { // Performs initialization, guarding it with the _initialization future. Future _ensureInitialized() async { - return _initialization ??= _doInitialization() - ..catchError((dynamic _) { - // Invalidate initialization if it errors out. - _initialization = null; - }); + return (_initialization ??= _doInitialization()).catchError((dynamic _) { + // Invalidate initialization if it errors out. + _initialization = null; + }); } // Actually performs the initialization. @@ -317,10 +316,10 @@ class GoogleSignIn { forceCodeForRefreshToken: forceCodeForRefreshToken, )); - GoogleSignInPlatform.instance.userDataEvents + unawaited(GoogleSignInPlatform.instance.userDataEvents ?.map((GoogleSignInUserData? userData) { return userData != null ? GoogleSignInAccount._(this, userData) : null; - }).forEach(_setCurrentUser); + }).forEach(_setCurrentUser)); } /// The most recently scheduled method call. diff --git a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart index b436a983fc7..a8c1d5cce77 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/google_sign_in_web.dart @@ -259,14 +259,14 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { Future signOut() async { await initialized; - _gisClient.signOut(); + await _gisClient.signOut(); } @override Future disconnect() async { await initialized; - _gisClient.disconnect(); + await _gisClient.disconnect(); } @override @@ -280,7 +280,7 @@ class GoogleSignInPlugin extends GoogleSignInPlatform { Future clearAuthCache({required String token}) async { await initialized; - _gisClient.clearAuthCache(); + await _gisClient.clearAuthCache(); } @override diff --git a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart index 612ac5a2ce9..c8d6ebfe1dc 100644 --- a/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart +++ b/packages/google_sign_in/google_sign_in_web/lib/src/gis_client.dart @@ -290,7 +290,7 @@ class GisSdkClient { /// Revokes the current authentication. Future signOut() async { - clearAuthCache(); + await clearAuthCache(); id.disableAutoSelect(); } @@ -299,7 +299,7 @@ class GisSdkClient { if (_lastTokenResponse != null) { oauth2.revoke(_lastTokenResponse!.access_token); } - signOut(); + await signOut(); } /// Returns true if the client has recognized this user before. diff --git a/packages/in_app_purchase/in_app_purchase/example/lib/main.dart b/packages/in_app_purchase/in_app_purchase/example/lib/main.dart index 21268d4e7e8..0f8818a07ff 100644 --- a/packages/in_app_purchase/in_app_purchase/example/lib/main.dart +++ b/packages/in_app_purchase/in_app_purchase/example/lib/main.dart @@ -440,7 +440,7 @@ class _MyAppState extends State<_MyApp> { purchaseDetails.status == PurchaseStatus.restored) { final bool valid = await _verifyPurchase(purchaseDetails); if (valid) { - deliverProduct(purchaseDetails); + unawaited(deliverProduct(purchaseDetails)); } else { _handleInvalidPurchase(purchaseDetails); return; diff --git a/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart b/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart index 7039d1b123c..9c2250f23e1 100644 --- a/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart +++ b/packages/in_app_purchase/in_app_purchase_android/example/lib/main.dart @@ -397,7 +397,7 @@ class _MyAppState extends State<_MyApp> { purchaseDetails.status == PurchaseStatus.restored) { final bool valid = await _verifyPurchase(purchaseDetails); if (valid) { - deliverProduct(purchaseDetails); + unawaited(deliverProduct(purchaseDetails)); } else { _handleInvalidPurchase(purchaseDetails); return; diff --git a/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/billing_client_manager_test.dart b/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/billing_client_manager_test.dart index 97f4640c7ee..11efbd165fc 100644 --- a/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/billing_client_manager_test.dart +++ b/packages/in_app_purchase/in_app_purchase_android/test/billing_client_wrappers/billing_client_manager_test.dart @@ -54,13 +54,13 @@ void main() { test('waits for connection before executing the operations', () async { final Completer calledCompleter1 = Completer(); final Completer calledCompleter2 = Completer(); - manager.runWithClient((BillingClient _) async { + unawaited(manager.runWithClient((BillingClient _) async { calledCompleter1.complete(); return const BillingResultWrapper(responseCode: BillingResponse.ok); - }); - manager.runWithClientNonRetryable( + })); + unawaited(manager.runWithClientNonRetryable( (BillingClient _) async => calledCompleter2.complete(), - ); + )); expect(calledCompleter1.isCompleted, equals(false)); expect(calledCompleter1.isCompleted, equals(false)); connectedCompleter.complete(); @@ -74,7 +74,7 @@ void main() { // Ensures all asynchronous connected code finishes. await manager.runWithClientNonRetryable((_) async {}); - manager.client.callHandler( + await manager.client.callHandler( const MethodCall(onBillingServiceDisconnectedCallback, {'handle': 0}), ); diff --git a/packages/palette_generator/test/palette_generator_test.dart b/packages/palette_generator/test/palette_generator_test.dart index 5e2e810a0d0..569f8123b2c 100644 --- a/packages/palette_generator/test/palette_generator_test.dart +++ b/packages/palette_generator/test/palette_generator_test.dart @@ -74,7 +74,7 @@ Future main() async { // We need to have a testWidgets test in order to initialize the image // cache for the other tests, but they timeout if they too are testWidgets // tests. - tester.pumpWidget(const Placeholder()); + await tester.pumpWidget(const Placeholder()); }); test( diff --git a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_safe_test.dart b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_safe_test.dart index c321ebac787..fb29452b428 100644 --- a/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_safe_test.dart +++ b/packages/pigeon/platform_tests/flutter_null_safe_unit_tests/test/null_safe_test.dart @@ -211,13 +211,13 @@ void main() { NullableReturnFlutterApi.setup(mockFlutterApi); final Completer resultCompleter = Completer(); - binding.defaultBinaryMessenger.handlePlatformMessage( + unawaited(binding.defaultBinaryMessenger.handlePlatformMessage( 'dev.flutter.pigeon.NullableReturnFlutterApi.doit', NullableReturnFlutterApi.codec.encodeMessage([]), (ByteData? data) { resultCompleter.complete(null); }, - ); + )); expect(resultCompleter.future, completion(null)); @@ -234,13 +234,13 @@ void main() { final Completer?> resultCompleter = Completer?>(); - binding.defaultBinaryMessenger.handlePlatformMessage( + unawaited(binding.defaultBinaryMessenger.handlePlatformMessage( 'dev.flutter.pigeon.NullableCollectionReturnFlutterApi.doit', NullableCollectionReturnFlutterApi.codec.encodeMessage([]), (ByteData? data) { resultCompleter.complete(null); }, - ); + )); expect(resultCompleter.future, completion(null)); diff --git a/packages/pigeon/tool/shared/process_utils.dart b/packages/pigeon/tool/shared/process_utils.dart index b00ffa5beee..a6a904b945f 100644 --- a/packages/pigeon/tool/shared/process_utils.dart +++ b/packages/pigeon/tool/shared/process_utils.dart @@ -28,8 +28,10 @@ Future runProcess(String command, List arguments, if (exitCode != 0 && logFailure) { // ignore: avoid_print print('$command $arguments failed:'); - process.stdout.pipe(stdout); - process.stderr.pipe(stderr); + await Future.wait(>[ + process.stdout.pipe(stdout), + process.stderr.pipe(stderr), + ]); } return exitCode; } diff --git a/packages/shared_preferences/shared_preferences_windows/example/integration_test/shared_preferences_test.dart b/packages/shared_preferences/shared_preferences_windows/example/integration_test/shared_preferences_test.dart index 00252008e85..cef19a68646 100644 --- a/packages/shared_preferences/shared_preferences_windows/example/integration_test/shared_preferences_test.dart +++ b/packages/shared_preferences/shared_preferences_windows/example/integration_test/shared_preferences_test.dart @@ -28,7 +28,7 @@ void main() { testWidgets('reading', (WidgetTester _) async { final SharedPreferencesWindows preferences = SharedPreferencesWindows(); - preferences.clear(); + await preferences.clear(); final Map values = await preferences.getAll(); expect(values['String'], isNull); expect(values['bool'], isNull); @@ -39,7 +39,7 @@ void main() { testWidgets('writing', (WidgetTester _) async { final SharedPreferencesWindows preferences = SharedPreferencesWindows(); - preferences.clear(); + await preferences.clear(); await preferences.setValue( 'String', 'flutter.String', kTestValues2['flutter.String']!); await preferences.setValue( @@ -60,7 +60,7 @@ void main() { testWidgets('removing', (WidgetTester _) async { final SharedPreferencesWindows preferences = SharedPreferencesWindows(); - preferences.clear(); + await preferences.clear(); const String key = 'flutter.testKey'; await preferences.setValue('String', key, kTestValues['flutter.String']!); await preferences.setValue('Bool', key, kTestValues['flutter.bool']!); @@ -75,7 +75,7 @@ void main() { testWidgets('clearing', (WidgetTester _) async { final SharedPreferencesWindows preferences = SharedPreferencesWindows(); - preferences.clear(); + await preferences.clear(); await preferences.setValue( 'String', 'flutter.String', kTestValues['flutter.String']!); await preferences.setValue( diff --git a/packages/web_benchmarks/lib/src/runner.dart b/packages/web_benchmarks/lib/src/runner.dart index 8ab5d2709b6..e47bc2de1b9 100644 --- a/packages/web_benchmarks/lib/src/runner.dart +++ b/packages/web_benchmarks/lib/src/runner.dart @@ -151,7 +151,7 @@ class BenchmarkServer { 'Requested to run benchmark ${benchmarkIterator.current}, but ' 'got results for $benchmarkName.', )); - server.close(); + unawaited(server.close()); } // Trace data is null when the benchmark is not frame-based, such as RawRecorder. @@ -180,7 +180,7 @@ class BenchmarkServer { } else if (request.requestedUri.path.endsWith('/on-error')) { final Map errorDetails = json.decode(await request.readAsString()) as Map; - server.close(); + unawaited(server.close()); // Keep the stack trace as a string. It's thrown in the browser, not this Dart VM. final String errorMessage = 'Caught browser-side error: ${errorDetails['error']}\n${errorDetails['stackTrace']}'; @@ -314,7 +314,7 @@ class BenchmarkServer { ); await chrome?.whenExits; } - server.close(); + unawaited(server.close()); } } } diff --git a/packages/webview_flutter/webview_flutter_web/example/integration_test/webview_flutter_test.dart b/packages/webview_flutter/webview_flutter_web/example/integration_test/webview_flutter_test.dart index f71d2d3c2ba..734ace71fa3 100644 --- a/packages/webview_flutter/webview_flutter_web/example/integration_test/webview_flutter_test.dart +++ b/packages/webview_flutter/webview_flutter_web/example/integration_test/webview_flutter_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; import 'dart:html' as html; import 'dart:io'; @@ -20,23 +21,23 @@ Future main() async { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); final HttpServer server = await HttpServer.bind(InternetAddress.anyIPv4, 0); - server.forEach((HttpRequest request) { + unawaited(server.forEach((HttpRequest request) { if (request.uri.path == '/hello.txt') { request.response.writeln('Hello, world.'); } else { fail('unexpected request: ${request.method} ${request.uri}'); } request.response.close(); - }); + })); final String prefixUrl = 'http://${server.address.address}:${server.port}'; final String primaryUrl = '$prefixUrl/hello.txt'; testWidgets('loadRequest', (WidgetTester tester) async { final WebWebViewController controller = - WebWebViewController(const PlatformWebViewControllerCreationParams()) - ..loadRequest( - LoadRequestParams(uri: Uri.parse(primaryUrl)), - ); + WebWebViewController(const PlatformWebViewControllerCreationParams()); + await controller.loadRequest( + LoadRequestParams(uri: Uri.parse(primaryUrl)), + ); await tester.pumpWidget( Directionality( @@ -58,10 +59,10 @@ Future main() async { testWidgets('loadHtmlString', (WidgetTester tester) async { final WebWebViewController controller = - WebWebViewController(const PlatformWebViewControllerCreationParams()) - ..loadHtmlString( - 'data:text/html;charset=utf-8,${Uri.encodeFull('test html')}', - ); + WebWebViewController(const PlatformWebViewControllerCreationParams()); + await controller.loadHtmlString( + 'data:text/html;charset=utf-8,${Uri.encodeFull('test html')}', + ); await tester.pumpWidget( Directionality( From 3002f3df6228a2a3f3f320c9aa0158c380f7237d Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 15:58:35 -0400 Subject: [PATCH 09/17] Better comment wording --- analysis_options.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index f329d6f31b1..4e9c9f38dc8 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -183,7 +183,7 @@ linter: - tighten_type_of_initializing_formals # - type_annotate_public_apis # subset of always_specify_types - type_init_formals - - unawaited_futures # DIFFERENT FROM FLUTTER/FLUTTER: Off there for too many false positives; not an issue here, and has been a source of bugs in the past. + - unawaited_futures # DIFFERENT FROM FLUTTER/FLUTTER: It's disable there for "too many false positives"; that's not an issue here, and this would have caught bugs in the past. - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_const From d747104b13da1c5d8e278f509f01cd1e0a25d037 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 15:58:42 -0400 Subject: [PATCH 10/17] CHANGELOGs and versions --- packages/camera/camera/CHANGELOG.md | 4 ++++ packages/camera/camera/pubspec.yaml | 2 +- packages/camera/camera_android/CHANGELOG.md | 4 ++++ packages/camera/camera_avfoundation/CHANGELOG.md | 4 ++++ packages/camera/camera_windows/CHANGELOG.md | 3 ++- packages/camera/camera_windows/pubspec.yaml | 2 +- packages/flutter_image/CHANGELOG.md | 3 ++- packages/flutter_image/pubspec.yaml | 2 +- packages/flutter_markdown/CHANGELOG.md | 1 + packages/go_router_builder/CHANGELOG.md | 3 ++- packages/go_router_builder/pubspec.yaml | 2 +- packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md | 4 ++++ packages/google_maps_flutter/google_maps_flutter/pubspec.yaml | 2 +- .../google_maps_flutter_android/CHANGELOG.md | 4 ++++ .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 4 ++++ packages/google_sign_in/google_sign_in/CHANGELOG.md | 4 ++++ packages/google_sign_in/google_sign_in/pubspec.yaml | 2 +- packages/google_sign_in/google_sign_in_web/CHANGELOG.md | 4 ++++ packages/google_sign_in/google_sign_in_web/pubspec.yaml | 2 +- packages/in_app_purchase/in_app_purchase/CHANGELOG.md | 3 ++- packages/in_app_purchase/in_app_purchase/pubspec.yaml | 2 +- packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md | 4 ++++ packages/in_app_purchase/in_app_purchase_android/pubspec.yaml | 2 +- packages/web_benchmarks/CHANGELOG.md | 4 ++++ packages/web_benchmarks/pubspec.yaml | 2 +- 25 files changed, 59 insertions(+), 14 deletions(-) diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md index 856f2bac5b3..206048ad592 100644 --- a/packages/camera/camera/CHANGELOG.md +++ b/packages/camera/camera/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.5+2 + +* Fixes unawaited_futures violations. + ## 0.10.5+1 * Removes obsolete null checks on non-nullable values. diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml index 5f18563836f..b5d916af86a 100644 --- a/packages/camera/camera/pubspec.yaml +++ b/packages/camera/camera/pubspec.yaml @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing Dart. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.10.5+1 +version: 0.10.5+2 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md index 28552d33c3a..8bfdd7f0b1f 100644 --- a/packages/camera/camera_android/CHANGELOG.md +++ b/packages/camera/camera_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Fixes unawaited_futures violations. + ## 0.10.8+2 * Removes obsolete null checks on non-nullable values. diff --git a/packages/camera/camera_avfoundation/CHANGELOG.md b/packages/camera/camera_avfoundation/CHANGELOG.md index 4a4be5f17c3..2133c7935c0 100644 --- a/packages/camera/camera_avfoundation/CHANGELOG.md +++ b/packages/camera/camera_avfoundation/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Fixes unawaited_futures violations. + ## 0.9.13+2 * Removes obsolete null checks on non-nullable values. diff --git a/packages/camera/camera_windows/CHANGELOG.md b/packages/camera/camera_windows/CHANGELOG.md index 65777d3c40f..634856646e0 100644 --- a/packages/camera/camera_windows/CHANGELOG.md +++ b/packages/camera/camera_windows/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 0.2.1+7 +* Fixes unawaited_futures violations. * Updates minimum supported SDK version to Flutter 3.3/Dart 2.18. ## 0.2.1+6 diff --git a/packages/camera/camera_windows/pubspec.yaml b/packages/camera/camera_windows/pubspec.yaml index c62cd5d4914..13e8a4415d6 100644 --- a/packages/camera/camera_windows/pubspec.yaml +++ b/packages/camera/camera_windows/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_windows description: A Flutter plugin for getting information about and controlling the camera on Windows. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_windows issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.2.1+6 +version: 0.2.1+7 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/flutter_image/CHANGELOG.md b/packages/flutter_image/CHANGELOG.md index a4b65bb1775..411b5921752 100644 --- a/packages/flutter_image/CHANGELOG.md +++ b/packages/flutter_image/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 4.1.6 +* Fixes unawaited_futures violations. * Updates minimum supported SDK version to Flutter 3.3/Dart 2.18. * Aligns Dart and Flutter SDK constraints. diff --git a/packages/flutter_image/pubspec.yaml b/packages/flutter_image/pubspec.yaml index 1021c8a1ba9..09901618c7d 100644 --- a/packages/flutter_image/pubspec.yaml +++ b/packages/flutter_image/pubspec.yaml @@ -3,7 +3,7 @@ description: > Image utilities for Flutter: improved network providers, effects, etc. repository: https://github.com/flutter/packages/tree/main/packages/flutter_image issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_image%22 -version: 4.1.5 +version: 4.1.6 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/flutter_markdown/CHANGELOG.md b/packages/flutter_markdown/CHANGELOG.md index 1c28f585f94..f6a3351e3c2 100644 --- a/packages/flutter_markdown/CHANGELOG.md +++ b/packages/flutter_markdown/CHANGELOG.md @@ -1,5 +1,6 @@ ## NEXT +* Fixes unawaited_futures violations. * Updates minimum Flutter version to 3.3. * Aligns Dart and Flutter SDK constraints. * Replace `describeEnum` with the `name` getter. diff --git a/packages/go_router_builder/CHANGELOG.md b/packages/go_router_builder/CHANGELOG.md index bdab45ea957..7ebb5768d4e 100644 --- a/packages/go_router_builder/CHANGELOG.md +++ b/packages/go_router_builder/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.0.2 +* Fixes unawaited_futures violations. * Updates minimum supported SDK version to Flutter 3.3/Dart 2.18. ## 2.0.1 diff --git a/packages/go_router_builder/pubspec.yaml b/packages/go_router_builder/pubspec.yaml index a8ae680e97a..322428dab54 100644 --- a/packages/go_router_builder/pubspec.yaml +++ b/packages/go_router_builder/pubspec.yaml @@ -2,7 +2,7 @@ name: go_router_builder description: >- A builder that supports generated strongly-typed route helpers for package:go_router -version: 2.0.1 +version: 2.0.2 repository: https://github.com/flutter/packages/tree/main/packages/go_router_builder issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router_builder%22 diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index b3ccb3741d8..f0c5c78a2e8 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.2.8 + +* Fixes unawaited_futures violations. + ## 2.2.7 * Removes obsolete null checks on non-nullable values. diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 48b15625689..b76ea7b28c5 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.2.7 +version: 2.2.8 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index 7b054ced127..4bec0d08bc3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Fixes unawaited_futures violations. + ## 2.4.15 * Removes obsolete null checks on non-nullable values. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 703010222f3..de714e6debe 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Fixes unawaited_futures violations. + ## 2.2.3 * Removes obsolete null checks on non-nullable values. diff --git a/packages/google_sign_in/google_sign_in/CHANGELOG.md b/packages/google_sign_in/google_sign_in/CHANGELOG.md index 1751c5cbfc9..75a8c77f92c 100644 --- a/packages/google_sign_in/google_sign_in/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.1.2 + +* Fixes unawaited_futures violations. + ## 6.1.1 * Removes obsolete null checks on non-nullable values. diff --git a/packages/google_sign_in/google_sign_in/pubspec.yaml b/packages/google_sign_in/google_sign_in/pubspec.yaml index 3ac3bf5aa79..b631873506d 100644 --- a/packages/google_sign_in/google_sign_in/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android and iOS. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 6.1.1 +version: 6.1.2 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md index 1a494cb297f..6ac12d9dc69 100644 --- a/packages/google_sign_in/google_sign_in_web/CHANGELOG.md +++ b/packages/google_sign_in/google_sign_in_web/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.12.0+1 + +* Fixes unawaited_futures violations. + ## 0.12.0 * Authentication: diff --git a/packages/google_sign_in/google_sign_in_web/pubspec.yaml b/packages/google_sign_in/google_sign_in_web/pubspec.yaml index 589aaac54c6..ccc8dc38007 100644 --- a/packages/google_sign_in/google_sign_in_web/pubspec.yaml +++ b/packages/google_sign_in/google_sign_in_web/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web. repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22 -version: 0.12.0 +version: 0.12.0+1 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md index c049d007a91..d27401df734 100644 --- a/packages/in_app_purchase/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 3.1.6 +* Fixes unawaited_futures violations. * Updates minimum supported SDK version to Flutter 3.3/Dart 2.18. * Aligns Dart and Flutter SDK constraints. diff --git a/packages/in_app_purchase/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/in_app_purchase/pubspec.yaml index d873338e28d..280727615de 100644 --- a/packages/in_app_purchase/in_app_purchase/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase description: A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store and Google Play. repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 3.1.5 +version: 3.1.6 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md index f1b22d6a620..34af66f18b8 100644 --- a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0+4 + +* Fixes unawaited_futures violations. + ## 0.3.0+3 * Fixes Java lint issues. diff --git a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml index 1267da2e5cd..ab7a3eb949c 100644 --- a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase_android description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs. repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 0.3.0+3 +version: 0.3.0+4 environment: sdk: ">=2.18.0 <4.0.0" diff --git a/packages/web_benchmarks/CHANGELOG.md b/packages/web_benchmarks/CHANGELOG.md index f01d493d792..4ffc655fe35 100644 --- a/packages/web_benchmarks/CHANGELOG.md +++ b/packages/web_benchmarks/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.0+5 + +* Fixes unawaited_futures violations. + ## 0.1.0+4 * Removes obsolete null checks on non-nullable values. diff --git a/packages/web_benchmarks/pubspec.yaml b/packages/web_benchmarks/pubspec.yaml index 18c833792ba..a3455ca5a0b 100644 --- a/packages/web_benchmarks/pubspec.yaml +++ b/packages/web_benchmarks/pubspec.yaml @@ -2,7 +2,7 @@ name: web_benchmarks description: A benchmark harness for performance-testing Flutter apps in Chrome. repository: https://github.com/flutter/packages/tree/main/packages/web_benchmarks issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+web_benchmarks%22 -version: 0.1.0+4 +version: 0.1.0+5 environment: sdk: ">=2.18.0 <4.0.0" From 12635936b21e9c591e4a2dc1e0f6409423951170 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 May 2023 16:35:51 -0400 Subject: [PATCH 11/17] Fix typo, reword again to not refer to relative time --- analysis_options.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4e9c9f38dc8..f32174dc81a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -183,7 +183,7 @@ linter: - tighten_type_of_initializing_formals # - type_annotate_public_apis # subset of always_specify_types - type_init_formals - - unawaited_futures # DIFFERENT FROM FLUTTER/FLUTTER: It's disable there for "too many false positives"; that's not an issue here, and this would have caught bugs in the past. + - unawaited_futures # DIFFERENT FROM FLUTTER/FLUTTER: It's disabled there for "too many false positives"; that's not an issue here, and missing awaits have caused production issues in plugins. - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_const From bed74b3fd7831bf850668a98078a5d9902f5aba3 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 24 May 2023 07:26:54 -0400 Subject: [PATCH 12/17] Move new rule into test dir --- packages/go_router/analysis_options.yaml | 6 +----- packages/go_router/test/analysis_options.yaml | 12 ++++++++++++ packages/go_router/test/go_router_test.dart | 2 +- packages/go_router/tool/run_tests.dart | 5 +++-- 4 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 packages/go_router/test/analysis_options.yaml diff --git a/packages/go_router/analysis_options.yaml b/packages/go_router/analysis_options.yaml index 1818d64f9c4..5e5c244496d 100644 --- a/packages/go_router/analysis_options.yaml +++ b/packages/go_router/analysis_options.yaml @@ -1,6 +1,6 @@ # This custom rule set only exists to allow very targeted changes # relative to the default repo settings, for specific use cases. -# Please do NOT add more changes here without consulting with +# Please do NOT add more changes here without consulting with # #hackers-ecosystem on Discord. include: ../../analysis_options.yaml @@ -9,7 +9,3 @@ analyzer: exclude: # This directory deliberately has errors, to test `fix`. - "test_fixes/**" -linter: - rules: - # Matches flutter/flutter, which disables this rule due to false positives. - unawaited_futures: false diff --git a/packages/go_router/test/analysis_options.yaml b/packages/go_router/test/analysis_options.yaml new file mode 100644 index 00000000000..1544b494d4c --- /dev/null +++ b/packages/go_router/test/analysis_options.yaml @@ -0,0 +1,12 @@ +# This custom rule set only exists to allow very targeted changes +# relative to the default repo settings, for specific use cases. +# Please do NOT add more changes here without consulting with +# #hackers-ecosystem on Discord. + +include: ../../analysis_options.yaml + +linter: + rules: + # Matches flutter/flutter, which disables this rule due to false positives + # from navigator APIs. + unawaited_futures: false diff --git a/packages/go_router/test/go_router_test.dart b/packages/go_router/test/go_router_test.dart index 532a4f64f01..cbdc543f464 100644 --- a/packages/go_router/test/go_router_test.dart +++ b/packages/go_router/test/go_router_test.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore_for_file: cascade_invocations, diagnostic_describe_all_properties +// ignore_for_file: cascade_invocations, diagnostic_describe_all_properties, unawaited_futures import 'dart:async'; diff --git a/packages/go_router/tool/run_tests.dart b/packages/go_router/tool/run_tests.dart index 58c689bf942..d3fb6b315bd 100644 --- a/packages/go_router/tool/run_tests.dart +++ b/packages/go_router/tool/run_tests.dart @@ -8,6 +8,7 @@ // ignore_for_file: avoid_print +import 'dart:async'; import 'dart:io'; import 'package:io/io.dart' as io; import 'package:path/path.dart' as p; @@ -99,8 +100,8 @@ dependencies: Future _streamOutput(Future processFuture) async { final Process process = await processFuture; - stdout.addStream(process.stdout); - stderr.addStream(process.stderr); + unawaited(stdout.addStream(process.stdout)); + unawaited(stderr.addStream(process.stderr)); return process; } From 14902248b3b82d9ec4c6dda0934a66f6260791e5 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 24 May 2023 07:30:59 -0400 Subject: [PATCH 13/17] Fix test hang --- .../google_identity_services_web/test/js_loader_test.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/google_identity_services_web/test/js_loader_test.dart b/packages/google_identity_services_web/test/js_loader_test.dart index 44809f1aba2..028f5fd602a 100644 --- a/packages/google_identity_services_web/test/js_loader_test.dart +++ b/packages/google_identity_services_web/test/js_loader_test.dart @@ -4,6 +4,8 @@ @TestOn('browser') // Uses package:js +import 'dart:async'; + import 'package:google_identity_services_web/loader.dart'; import 'package:google_identity_services_web/src/js_interop/dom.dart' as dom; import 'package:google_identity_services_web/src/js_loader.dart'; @@ -27,7 +29,9 @@ void main() { final dom.DomHtmlElement target = dom.document.createElement('div'); test('Injects script into desired target', () async { - await loadWebSdk(target: target); + // This test doesn't simulate the callback that completes the future, and + // the code being tested runs synchronously. + unawaited(loadWebSdk(target: target)); // Target now should have a child that is a script element final Object children = js_util.getProperty(target, 'children'); From e92cac80d82dfc995cbc13db1f07a8d36a7fe356 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 24 May 2023 08:11:43 -0400 Subject: [PATCH 14/17] Restore passing errors through google_sign_in init --- .../google_sign_in/google_sign_in/lib/google_sign_in.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart index 8068181f842..2098244c90e 100644 --- a/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart +++ b/packages/google_sign_in/google_sign_in/lib/google_sign_in.dart @@ -296,10 +296,13 @@ class GoogleSignIn { // Performs initialization, guarding it with the _initialization future. Future _ensureInitialized() async { - return (_initialization ??= _doInitialization()).catchError((dynamic _) { + _initialization ??= _doInitialization().catchError((Object e) { // Invalidate initialization if it errors out. _initialization = null; + // ignore: only_throw_errors + throw e; }); + return _initialization; } // Actually performs the initialization. From 8909565cb5d5d91b0b5beccf56b54cca348ed17d Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 24 May 2023 08:26:55 -0400 Subject: [PATCH 15/17] Update excerpts --- packages/google_maps_flutter/google_maps_flutter/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/README.md b/packages/google_maps_flutter/google_maps_flutter/README.md index 7a97d99d447..ea15dfc1f74 100644 --- a/packages/google_maps_flutter/google_maps_flutter/README.md +++ b/packages/google_maps_flutter/google_maps_flutter/README.md @@ -154,7 +154,7 @@ class MapSampleState extends State { Future _goToTheLake() async { final GoogleMapController controller = await _controller.future; - controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); + await controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); } } ``` From 86e18bfebbc8a16c8d7a74649d6b42739c97ebc2 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 24 May 2023 08:29:18 -0400 Subject: [PATCH 16/17] Ignore analysis options changes for version check --- script/tool/lib/src/common/package_state_utils.dart | 3 ++- script/tool/test/version_check_command_test.dart | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/script/tool/lib/src/common/package_state_utils.dart b/script/tool/lib/src/common/package_state_utils.dart index bb0960cd1ce..fdc816143ab 100644 --- a/script/tool/lib/src/common/package_state_utils.dart +++ b/script/tool/lib/src/common/package_state_utils.dart @@ -177,7 +177,8 @@ Future _isDevChange(List pathComponents, // Entry point for the 'custom-test' command, which is only for CI and // local testing. pathComponents.first == 'run_tests.sh' || - // Ignoring lints doesn't affect clients. + // Lints don't affect clients. + pathComponents.contains('analysis_options.yaml') || pathComponents.contains('lint-baseline.xml') || // Example build files are very unlikely to be interesting to clients. _isExampleBuildFile(pathComponents) || diff --git a/script/tool/test/version_check_command_test.dart b/script/tool/test/version_check_command_test.dart index f3e6f9227dc..c6d93398264 100644 --- a/script/tool/test/version_check_command_test.dart +++ b/script/tool/test/version_check_command_test.dart @@ -879,6 +879,7 @@ packages/plugin/example/android/lint-baseline.xml packages/plugin/example/android/src/androidTest/foo/bar/FooTest.java packages/plugin/example/ios/RunnerTests/Foo.m packages/plugin/example/ios/RunnerUITests/info.plist +packages/plugin/analysis_options.yaml packages/plugin/CHANGELOG.md ''')), ]; From 0b8a5ec03db6427ebab73097e8885ce0204e4332 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 24 May 2023 09:22:34 -0400 Subject: [PATCH 17/17] Fix include path --- packages/go_router/test/analysis_options.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go_router/test/analysis_options.yaml b/packages/go_router/test/analysis_options.yaml index 1544b494d4c..6e56bce4ccc 100644 --- a/packages/go_router/test/analysis_options.yaml +++ b/packages/go_router/test/analysis_options.yaml @@ -3,7 +3,7 @@ # Please do NOT add more changes here without consulting with # #hackers-ecosystem on Discord. -include: ../../analysis_options.yaml +include: ../../../analysis_options.yaml linter: rules: