diff --git a/packages/devtools_app/lib/src/extensions/extension_service.dart b/packages/devtools_app/lib/src/extensions/extension_service.dart index d27a29ee866..1e69c5a145b 100644 --- a/packages/devtools_app/lib/src/extensions/extension_service.dart +++ b/packages/devtools_app/lib/src/extensions/extension_service.dart @@ -297,14 +297,14 @@ class ExtensionService extends DisposableController ...runtimeExtensions, ...staticExtensions, ].where((e) => e.name == extension.name); - await Future.wait([ + await [ for (final ext in allMatchingExtensions) server.extensionEnabledState( devtoolsOptionsFileUri: ext.devtoolsOptionsUri, extensionName: ext.name, enable: enable, ), - ]); + ].wait; await _refreshExtensionEnabledStates( availableExtensions: _currentExtensions.value.availableExtensions, ); diff --git a/packages/devtools_app/lib/src/screens/debugger/breakpoint_manager.dart b/packages/devtools_app/lib/src/screens/debugger/breakpoint_manager.dart index 45c3e56bdc6..4c672e7418f 100644 --- a/packages/devtools_app/lib/src/screens/debugger/breakpoint_manager.dart +++ b/packages/devtools_app/lib/src/screens/debugger/breakpoint_manager.dart @@ -180,7 +180,7 @@ class BreakpointManager with DisposerMixin { } } - await Future.wait([ + await [ // Remove the breakpoints. for (final bp in breakpointsToRemove) removeBreakpoint(bp.breakpoint), // Add them back to the newer versions of those scripts. @@ -189,7 +189,7 @@ class BreakpointManager with DisposerMixin { if (scriptRef.uri == bp.scriptUri) addBreakpoint(scriptRef.id!, bp.line!), ], - ]); + ].wait; } Future> _getBreakpointsForIsolate(String isolateId) async { @@ -214,15 +214,17 @@ class BreakpointManager with DisposerMixin { }) async { _breakpoints.value = breakpoints; // Build _breakpointsWithLocation from _breakpoints. - await Future.wait( - _breakpoints.value.map(breakpointManager.createBreakpointWithLocation), - ).then((list) { - if (isolateId != _isolateRefId) { - // Current request is obsolete. - return; - } - _breakpointsWithLocation.value = list.toList()..sort(); - }); + final breakpointsWithLocation = + await _breakpoints.value + .map(breakpointManager.createBreakpointWithLocation) + .wait; + + if (isolateId != _isolateRefId) { + // Current request is obsolete. + return; + } + + _breakpointsWithLocation.value = breakpointsWithLocation.sorted(); } Future _setUpBreakpoints({ diff --git a/packages/devtools_app/lib/src/screens/debugger/debugger_controller.dart b/packages/devtools_app/lib/src/screens/debugger/debugger_controller.dart index efd69a9af1f..a3b1822b232 100644 --- a/packages/devtools_app/lib/src/screens/debugger/debugger_controller.dart +++ b/packages/devtools_app/lib/src/screens/debugger/debugger_controller.dart @@ -453,7 +453,7 @@ class DebuggerController extends DisposableController ); return _StackInfo( - await Future.wait(frames.map(_createStackFrameWithLocation)), + await frames.map(_createStackFrameWithLocation).wait, stack.truncated ?? false, ); } diff --git a/packages/devtools_app/lib/src/screens/debugger/program_explorer_controller.dart b/packages/devtools_app/lib/src/screens/debugger/program_explorer_controller.dart index 99f0ab25d64..a4106fcf5cf 100644 --- a/packages/devtools_app/lib/src/screens/debugger/program_explorer_controller.dart +++ b/packages/devtools_app/lib/src/screens/debugger/program_explorer_controller.dart @@ -254,47 +254,44 @@ class ProgramExplorerController extends DisposableController .id; Future> getObjects(Iterable objs) { - return Future.wait( - objs.map((o) => service!.getObject(isolateId!, o.id!)), - ); + return objs.map((o) => service!.getObject(isolateId!, o.id!)).wait; } Future> getFuncs( Iterable funcs, Iterable? fields, ) async { - return await Future.wait( - funcs - .where((f) => !_isSyntheticAccessor(f, fields as List)) - .map>( - (f) => service!.getObject(isolateId!, f.id!).then((f) async { - final func = f as Func; - final codeRef = func.code; - - // Populate the [Code] objects in each function if we want to - // show code nodes in the outline. - if (showCodeNodes && codeRef != null) { - final code = - await service.getObject(isolateId, codeRef.id!) as Code; - func.code = code; - Code unoptimizedCode = code; - // `func.code` could be unoptimized code, so don't bother - // fetching it again. - if (func.unoptimizedCode != null && - func.unoptimizedCode?.id! != code.id!) { - unoptimizedCode = - await service.getObject( - isolateId, - func.unoptimizedCode!.id!, - ) - as Code; - } - func.unoptimizedCode = unoptimizedCode; + return await funcs + .where((f) => !_isSyntheticAccessor(f, fields as List)) + .map>( + (f) => service!.getObject(isolateId!, f.id!).then((f) async { + final func = f as Func; + final codeRef = func.code; + + // Populate the [Code] objects in each function if we want to + // show code nodes in the outline. + if (showCodeNodes && codeRef != null) { + final code = + await service.getObject(isolateId, codeRef.id!) as Code; + func.code = code; + Code unoptimizedCode = code; + // `func.code` could be unoptimized code, so don't bother + // fetching it again. + if (func.unoptimizedCode != null && + func.unoptimizedCode?.id! != code.id!) { + unoptimizedCode = + await service.getObject( + isolateId, + func.unoptimizedCode!.id!, + ) + as Code; } - return func; - }), - ), - ); + func.unoptimizedCode = unoptimizedCode; + } + return func; + }), + ) + .wait; } try { @@ -302,21 +299,23 @@ class ProgramExplorerController extends DisposableController return; } else if (object is LibraryRef) { final lib = await service!.getObject(isolateId!, object.id!) as Library; - final results = await Future.wait([ - getObjects(lib.variables!), - getFuncs(lib.functions!, lib.variables), - ]); - lib.variables = results[0].cast(); - lib.functions = results[1].cast(); + final (variableObjects, functionObjects) = + await ( + getObjects(lib.variables!), + getFuncs(lib.functions!, lib.variables), + ).wait; + lib.variables = variableObjects.cast(); + lib.functions = functionObjects; node.updateObject(lib); } else if (object is ClassRef) { final clazz = await service!.getObject(isolateId!, object.id!) as Class; - final results = await Future.wait([ - getObjects(clazz.fields!), - getFuncs(clazz.functions!, clazz.fields), - ]); - clazz.fields = results[0].cast(); - clazz.functions = results[1].cast(); + final (fieldObjects, functionObjects) = + await ( + getObjects(clazz.fields!), + getFuncs(clazz.functions!, clazz.fields), + ).wait; + clazz.fields = fieldObjects.cast(); + clazz.functions = functionObjects; node.updateObject(clazz); } else { final obj = await service!.getObject(isolateId!, object.id!); diff --git a/packages/devtools_app/lib/src/screens/debugger/variables.dart b/packages/devtools_app/lib/src/screens/debugger/variables.dart index de9b07faedc..ba8f8e2a43f 100644 --- a/packages/devtools_app/lib/src/screens/debugger/variables.dart +++ b/packages/devtools_app/lib/src/screens/debugger/variables.dart @@ -55,7 +55,7 @@ class Variables extends StatelessWidget { Future onItemPressed(DartObjectNode v) async { // On expansion, lazily build the variables tree for performance reasons. if (v.isExpanded) { - await Future.wait(v.children.map(buildVariablesTree)); + await v.children.map(buildVariablesTree).wait; } } } diff --git a/packages/devtools_app/lib/src/screens/inspector/inspector_controller.dart b/packages/devtools_app/lib/src/screens/inspector/inspector_controller.dart index b0ef7300a0e..2b67e7f68e9 100644 --- a/packages/devtools_app/lib/src/screens/inspector/inspector_controller.dart +++ b/packages/devtools_app/lib/src/screens/inspector/inspector_controller.dart @@ -328,10 +328,10 @@ class InspectorController extends DisposableController final detailsLocal = details; if (detailsLocal == null) return _waitForPendingUpdateDone(); - return Future.wait([ + return [ _waitForPendingUpdateDone(), detailsLocal._waitForPendingUpdateDone(), - ]); + ].wait; } // Note that this may be called after the controller is disposed. We need to handle nulls in the fields. diff --git a/packages/devtools_app/lib/src/screens/memory/panes/diff/controller/diff_pane_controller.dart b/packages/devtools_app/lib/src/screens/memory/panes/diff/controller/diff_pane_controller.dart index 2f76ffe503b..2f876fa327b 100644 --- a/packages/devtools_app/lib/src/screens/memory/panes/diff/controller/diff_pane_controller.dart +++ b/packages/devtools_app/lib/src/screens/memory/panes/diff/controller/diff_pane_controller.dart @@ -129,7 +129,7 @@ class DiffPaneController extends DisposableController with Serializable { final item = SnapshotDataItem(defaultName: file.name); await _addSnapshot(HeapGraphLoaderFile(file), item); }); - await Future.wait(importers); + await importers.wait; derived._updateValues(); } diff --git a/packages/devtools_app/lib/src/screens/memory/panes/tracing/tracing_data.dart b/packages/devtools_app/lib/src/screens/memory/panes/tracing/tracing_data.dart index 31495ba47c5..3bec4f1eca7 100644 --- a/packages/devtools_app/lib/src/screens/memory/panes/tracing/tracing_data.dart +++ b/packages/devtools_app/lib/src/screens/memory/panes/tracing/tracing_data.dart @@ -192,7 +192,7 @@ class TracingIsolateState with Serializable { // All profile requests need to complete before we can consider the refresh // completed. - await Future.wait(profileRequests); + await profileRequests.wait; } void updateClassFilter(String newFilter, {bool force = false}) { diff --git a/packages/devtools_app/lib/src/screens/network/network_controller.dart b/packages/devtools_app/lib/src/screens/network/network_controller.dart index bc61b25214a..4616c1fcbf8 100644 --- a/packages/devtools_app/lib/src/screens/network/network_controller.dart +++ b/packages/devtools_app/lib/src/screens/network/network_controller.dart @@ -266,10 +266,10 @@ class NetworkController extends DisposableController // TODO(kenz): only call these if http logging and socket profiling are not // already enabled. Listen to service manager streams for this info. - await Future.wait([ + await [ http_service.toggleHttpRequestLogging(true), networkService.toggleSocketProfiling(true), - ]); + ].wait; await togglePolling(true); } @@ -400,11 +400,11 @@ class NetworkController extends DisposableController } } - Future _fetchFullDataBeforeExport() => Future.wait( - filteredData.value.whereType().map( - (item) => item.getFullRequestData(), - ), - ); + Future _fetchFullDataBeforeExport() => + filteredData.value + .whereType() + .map((item) => item.getFullRequestData()) + .wait; } /// Class for managing the set of all current sockets, and diff --git a/packages/devtools_app/lib/src/screens/performance/panes/controls/enhance_tracing/enhance_tracing.dart b/packages/devtools_app/lib/src/screens/performance/panes/controls/enhance_tracing/enhance_tracing.dart index b08fbe787c0..c8e2857fbff 100644 --- a/packages/devtools_app/lib/src/screens/performance/panes/controls/enhance_tracing/enhance_tracing.dart +++ b/packages/devtools_app/lib/src/screens/performance/panes/controls/enhance_tracing/enhance_tracing.dart @@ -307,7 +307,7 @@ class TraceWidgetBuildsCheckbox extends StatelessWidget { value: extension.enabledValue, ); } else { - await Future.wait([ + await [ for (final extension in tracingExtensions) serviceConnection.serviceManager.serviceExtensionManager .setServiceExtensionState( @@ -315,7 +315,7 @@ class TraceWidgetBuildsCheckbox extends StatelessWidget { enabled: false, value: extension.disabledValue, ), - ]); + ].wait; } } } @@ -366,7 +366,7 @@ class TraceWidgetBuildsScopeSelector extends StatelessWidget { assert(enabled); final extension = type!.extensionForScope; final opposite = type.opposite.extensionForScope; - await Future.wait([ + await [ serviceConnection.serviceManager.serviceExtensionManager .setServiceExtensionState( opposite.extension, @@ -379,6 +379,6 @@ class TraceWidgetBuildsScopeSelector extends StatelessWidget { enabled: true, value: extension.enabledValue, ), - ]); + ].wait; } } diff --git a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart index c51887e251e..de4c5a18e3c 100644 --- a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart +++ b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart @@ -210,11 +210,10 @@ class PerformanceController extends DisposableController await futureOr(controller); } - final futures = >[]; - for (final controller in _featureControllers) { - futures.add(helper(callback, controller)); - } - await Future.wait(futures); + await [ + for (final controller in _featureControllers) + helper(callback, controller), + ].wait; } Future setActiveFeature( diff --git a/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/class_hierarchy_explorer_controller.dart b/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/class_hierarchy_explorer_controller.dart index 782f4ef8809..7845ddfe9a0 100644 --- a/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/class_hierarchy_explorer_controller.dart +++ b/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/class_hierarchy_explorer_controller.dart @@ -26,10 +26,11 @@ class ClassHierarchyExplorerController { final isolateId = isolate.id!; final classList = await service.getClassList(isolateId); // TODO(bkonyi): we should cache the class list like we do the script list - final classes = await Future.wait([ - for (final cls in classList.classes!) - service.getObject(isolateId, cls.id!).then((e) => e as Class), - ]); + final classes = + await [ + for (final cls in classList.classes!) + service.getObject(isolateId, cls.id!).then((e) => e as Class), + ].wait; buildHierarchy(classes); } diff --git a/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_ic_data_display.dart b/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_ic_data_display.dart index e8dba62c504..029c56e3696 100644 --- a/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_ic_data_display.dart +++ b/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_ic_data_display.dart @@ -82,10 +82,10 @@ class _VmICDataDisplayState extends State { final entriesFuture = service .getObject(isolateId, icData.entries.id!) .then((e) => e as Instance); - _initialized = Future.wait([ + _initialized = [ argumentsDescriptorFuture, entriesFuture, - ]).then((result) => populateLists(result[0], result[1])); + ].wait.then((result) => populateLists(result[0], result[1])); } @override diff --git a/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_instance_display.dart b/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_instance_display.dart index 38d66c086de..c29ac2eebca 100644 --- a/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_instance_display.dart +++ b/packages/devtools_app/lib/src/screens/vm_developer/object_inspector/vm_instance_display.dart @@ -67,9 +67,9 @@ class _VmInstanceDisplayState extends State { .then((_) => _root.expand()) .then( (_) => unawaited( - Future.wait([ + [ for (final child in _root.children) buildVariablesTree(child), - ]), + ].wait, ), ), ); diff --git a/packages/devtools_app/lib/src/screens/vm_developer/vm_statistics/vm_statistics_view_controller.dart b/packages/devtools_app/lib/src/screens/vm_developer/vm_statistics/vm_statistics_view_controller.dart index 789b9f329aa..a46fa433903 100644 --- a/packages/devtools_app/lib/src/screens/vm_developer/vm_statistics/vm_statistics_view_controller.dart +++ b/packages/devtools_app/lib/src/screens/vm_developer/vm_statistics/vm_statistics_view_controller.dart @@ -21,12 +21,9 @@ class VMStatisticsViewController extends DisposableController { _refreshing.value = true; final vm = await _service.getVM(); _vm = vm; - _isolates = await Future.wait( - vm.isolates!.map((i) => _service.getIsolate(i.id!)), - ); - _systemIsolates = await Future.wait( - vm.systemIsolates!.map((i) => _service.getIsolate(i.id!)), - ); + _isolates = await vm.isolates!.map((i) => _service.getIsolate(i.id!)).wait; + _systemIsolates = + await vm.systemIsolates!.map((i) => _service.getIsolate(i.id!)).wait; _refreshing.value = false; } diff --git a/packages/devtools_app/lib/src/service/editor/editor_client.dart b/packages/devtools_app/lib/src/service/editor/editor_client.dart index ffd26998a24..f732d108ce6 100644 --- a/packages/devtools_app/lib/src/service/editor/editor_client.dart +++ b/packages/devtools_app/lib/src/service/editor/editor_client.dart @@ -103,7 +103,7 @@ class EditorClient extends DisposableController } }), ); - await Future.wait([ + await [ _dtd.streamListen('Service'), _dtd.streamListen(editorStreamName).catchError((_) { // Because we currently call streamListen in two places (here and @@ -111,7 +111,7 @@ class EditorClient extends DisposableController // however we should refactor this code to better support using the DTD // connection in multiple places without them having to coordinate. }), - ]); + ].wait; } /// Close the connection to DTD. diff --git a/packages/devtools_app/lib/src/shared/console/eval/auto_complete.dart b/packages/devtools_app/lib/src/shared/console/eval/auto_complete.dart index c037e30e7e5..cfa4e36e717 100644 --- a/packages/devtools_app/lib/src/shared/console/eval/auto_complete.dart +++ b/packages/devtools_app/lib/src/shared/console/eval/auto_complete.dart @@ -158,7 +158,7 @@ Future> _libraryMemberAndImportsAutocompletes( } } } - (await Future.wait(futures)).forEach(result.addAll); + (await futures.wait).forEach(result.addAll); } catch (_) { // Silently skip library completions if there is a failure. } @@ -227,7 +227,7 @@ Future> _libraryMemberAutocompletes( } } if (futures.isNotEmpty) { - (await Future.wait(futures)).forEach(result.addAll); + (await futures.wait).forEach(result.addAll); } } return result; diff --git a/packages/devtools_app/lib/src/shared/console/widgets/description.dart b/packages/devtools_app/lib/src/shared/console/widgets/description.dart index 73b6d27240e..ac3d9c606ac 100644 --- a/packages/devtools_app/lib/src/shared/console/widgets/description.dart +++ b/packages/devtools_app/lib/src/shared/console/widgets/description.dart @@ -234,7 +234,7 @@ class DiagnosticsNodeDescription extends StatelessWidget { if (!isHoverStale()) await buildVariablesTree(child); }()); } - await Future.wait(tasks); + await tasks.wait; variable.expand(); return HoverCardData( diff --git a/packages/devtools_app/lib/src/shared/console/widgets/expandable_variable.dart b/packages/devtools_app/lib/src/shared/console/widgets/expandable_variable.dart index 9800fa0d102..0d40bcec008 100644 --- a/packages/devtools_app/lib/src/shared/console/widgets/expandable_variable.dart +++ b/packages/devtools_app/lib/src/shared/console/widgets/expandable_variable.dart @@ -57,7 +57,7 @@ class ExpandableVariable extends StatelessWidget { Future onItemPressed(DartObjectNode v) async { // On expansion, lazily build the variables tree for performance reasons. if (v.isExpanded) { - await Future.wait(v.children.map(buildVariablesTree)); + await v.children.map(buildVariablesTree).wait; } } } diff --git a/packages/devtools_app/lib/src/shared/diagnostics/tree_builder.dart b/packages/devtools_app/lib/src/shared/diagnostics/tree_builder.dart index 95673a79018..f24d9f141f9 100644 --- a/packages/devtools_app/lib/src/shared/diagnostics/tree_builder.dart +++ b/packages/devtools_app/lib/src/shared/diagnostics/tree_builder.dart @@ -36,7 +36,7 @@ Future _addExpandableChildren( variable.addChild(child); } if (tasks.isNotEmpty) { - await Future.wait(tasks); + await tasks.wait; } } @@ -337,7 +337,7 @@ Future _addInspectorItems( tasks.add(maybeUpdateRef(child)); } if (tasks.isNotEmpty) { - await Future.wait(tasks); + await tasks.wait; unawaited(group?.dispose()); } } diff --git a/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart b/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart index 75417b1fa6a..5cc11090789 100644 --- a/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart +++ b/packages/devtools_app/lib/src/shared/diagnostics/variable_factory.dart @@ -327,7 +327,7 @@ Future> createVariablesForDiagnostics( if (diagnostic.level == DiagnosticLevel.hidden) continue; variables.add(_buildVariable(diagnostic, objectGroupApi, isolateRef)); } - return variables.isNotEmpty ? await Future.wait(variables) : const []; + return variables.isNotEmpty ? await variables.wait : const []; } List createVariablesForMap( diff --git a/packages/devtools_app/lib/src/shared/primitives/custom_pointer_scroll_view.dart b/packages/devtools_app/lib/src/shared/primitives/custom_pointer_scroll_view.dart index df01e12c338..05f05c09552 100644 --- a/packages/devtools_app/lib/src/shared/primitives/custom_pointer_scroll_view.dart +++ b/packages/devtools_app/lib/src/shared/primitives/custom_pointer_scroll_view.dart @@ -288,7 +288,7 @@ class CustomPointerScrollable extends StatefulWidget { return Future.value(); } if (futures.length == 1) return futures.single; - return Future.wait(futures).then((List _) => null); + return futures.wait.then((List _) => null); } } diff --git a/packages/devtools_app/lib/src/shared/ui/common_widgets.dart b/packages/devtools_app/lib/src/shared/ui/common_widgets.dart index 96ae4839946..a6aa91a7959 100644 --- a/packages/devtools_app/lib/src/shared/ui/common_widgets.dart +++ b/packages/devtools_app/lib/src/shared/ui/common_widgets.dart @@ -1099,7 +1099,7 @@ class _JsonViewerState extends State { // Build the root node await buildVariablesTree(variable); // Build the contents of all children - await Future.wait(variable.children.map(buildVariablesTree)); + await variable.children.map(buildVariablesTree).wait; // Expand the root node to show the first level of contents variable.expand(); diff --git a/packages/devtools_app/test/legacy_integration_tests/integration.dart b/packages/devtools_app/test/legacy_integration_tests/integration.dart index f43d96065ea..8f47012d19b 100644 --- a/packages/devtools_app/test/legacy_integration_tests/integration.dart +++ b/packages/devtools_app/test/legacy_integration_tests/integration.dart @@ -38,15 +38,15 @@ class DevtoolsManager { ); await tabInstance.tab.navigate('${overrideUri ?? baseAppUri}'); - // wait for app initialization - await Future.wait([ + // Wait for app initialization. + await [ waitForConnection ? tabInstance.onEvent.firstWhere( (msg) => msg.event == 'app.devToolsReady', ) : Future.value(), tabInstance.getBrowserChannel(), - ]); + ].wait; } Future switchPage(String page) async { diff --git a/packages/devtools_app/test/test_infra/flutter_test_driver.dart b/packages/devtools_app/test/test_infra/flutter_test_driver.dart index ca165c96a5d..c7e25b08c00 100644 --- a/packages/devtools_app/test/test_infra/flutter_test_driver.dart +++ b/packages/devtools_app/test/test_infra/flutter_test_driver.dart @@ -366,10 +366,10 @@ class FlutterRunTestDriver extends FlutterTestDriver { final vmServiceLocal = vmService!; vmServiceLocal.onSend.listen((String s) => _debugPrint('==> $s')); vmServiceLocal.onReceive.listen((String s) => _debugPrint('<== $s')); - await Future.wait(>[ + await [ vmServiceLocal.streamListen(EventStreams.kIsolate), vmServiceLocal.streamListen(EventStreams.kDebug), - ]); + ].wait; // On hot restarts, the isolate ID we have for the Flutter thread will // exit so we need to invalidate our cached ID. diff --git a/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart b/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart index bbedd298b28..81f0905355d 100644 --- a/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart +++ b/packages/devtools_app/test/test_infra/scenes/standalone_ui/editor_service/simulated_editor.dart @@ -45,7 +45,7 @@ class SimulatedEditor { Stream get log => _logger.stream; Future _registerServices() { - return Future.wait([ + return [ _registerService(EditorMethod.getDevices, _getDevices), _registerService(EditorMethod.selectDevice, _selectDevice), _registerService(EditorMethod.getDebugSessions, _getDebugSessions), @@ -57,7 +57,7 @@ class SimulatedEditor { capabilities: {Field.supportsForceExternal: true}, ), _registerService(EditorMethod.enablePlatformType, _enablePlatformType), - ]); + ].wait; } /// Whether the editor is currently connected to DTD. diff --git a/packages/devtools_app_shared/lib/src/service/connected_app.dart b/packages/devtools_app_shared/lib/src/service/connected_app.dart index ce86e9e5aee..60a51a77ba4 100644 --- a/packages/devtools_app_shared/lib/src/service/connected_app.dart +++ b/packages/devtools_app_shared/lib/src/service/connected_app.dart @@ -152,7 +152,7 @@ class ConnectedApp { assert(serviceManager!.isServiceAvailable); - await Future.wait([isFlutterApp, isProfileBuild, isDartWebApp]); + await [isFlutterApp, isProfileBuild, isDartWebApp].wait; _operatingSystem = serviceManager!.vm!.operatingSystem ?? unknownOS; diff --git a/packages/devtools_app_shared/lib/src/service/isolate_manager.dart b/packages/devtools_app_shared/lib/src/service/isolate_manager.dart index f3573eeac76..dffb4491dfc 100644 --- a/packages/devtools_app_shared/lib/src/service/isolate_manager.dart +++ b/packages/devtools_app_shared/lib/src/service/isolate_manager.dart @@ -95,9 +95,9 @@ final class IsolateManager with DisposerMixin { Future initIsolates(List isolates) async { _clearIsolateStates(); - await Future.wait([ + await [ for (final isolateRef in isolates) _registerIsolate(isolateRef), - ]); + ].wait; // It is critical that the _serviceExtensionManager is already listening // for events indicating that new extension rpcs are registered before this diff --git a/packages/devtools_app_shared/lib/src/service/service_extension_manager.dart b/packages/devtools_app_shared/lib/src/service/service_extension_manager.dart index d4aae69edb6..9555bfe8f6b 100644 --- a/packages/devtools_app_shared/lib/src/service/service_extension_manager.dart +++ b/packages/devtools_app_shared/lib/src/service/service_extension_manager.dart @@ -149,10 +149,10 @@ final class ServiceExtensionManager with DisposerMixin { final extensionsToProcess = _pendingServiceExtensions.toList(); _pendingServiceExtensions.clear(); - await Future.wait([ + await [ for (final extension in extensionsToProcess) - _addServiceExtension(extension), - ]); + _addServiceExtension(extension) + ].wait; } Future _onMainIsolateChanged() async { @@ -185,15 +185,15 @@ final class ServiceExtensionManager with DisposerMixin { // Isolate has changed again. return; } - await Future.wait([ + await [ for (final extension in mainIsolate.extensionRPCs!) - _maybeAddServiceExtension(extension), - ]); + _maybeAddServiceExtension(extension) + ].wait; } else { - await Future.wait([ + await [ for (final extension in mainIsolate.extensionRPCs!) - _addServiceExtension(extension), - ]); + _addServiceExtension(extension) + ].wait; } } } diff --git a/packages/devtools_app_shared/lib/src/service/service_manager.dart b/packages/devtools_app_shared/lib/src/service/service_manager.dart index b1dbd285dfd..e0b0361d592 100644 --- a/packages/devtools_app_shared/lib/src/service/service_manager.dart +++ b/packages/devtools_app_shared/lib/src/service/service_manager.dart @@ -223,7 +223,7 @@ class ServiceManager { ) async { final callbacks = _lifecycleCallbacks[lifecycle] ?? >[]; - await Future.wait(callbacks.map((c) async => await c.call(service))); + await callbacks.map((c) async => await c.call(service)).wait; } final _overrides = >{}; diff --git a/packages/devtools_app_shared/lib/src/service/service_utils.dart b/packages/devtools_app_shared/lib/src/service/service_utils.dart index b3c54557aa1..55033179327 100644 --- a/packages/devtools_app_shared/lib/src/service/service_utils.dart +++ b/packages/devtools_app_shared/lib/src/service/service_utils.dart @@ -77,9 +77,5 @@ Future forEachIsolateHelper( Future Function(IsolateRef) callback, ) async { final vm = await vmService.getVM(); - final futures = >[]; - for (final isolate in vm.isolates ?? []) { - futures.add(callback(isolate)); - } - await Future.wait(futures); + await [for (final isolate in vm.isolates ?? []) callback(isolate)].wait; } diff --git a/packages/devtools_shared/lib/src/server/handlers/_general.dart b/packages/devtools_shared/lib/src/server/handlers/_general.dart index d309b771701..c9dd9c4e9a4 100644 --- a/packages/devtools_shared/lib/src/server/handlers/_general.dart +++ b/packages/devtools_shared/lib/src/server/handlers/_general.dart @@ -201,12 +201,9 @@ extension on VmService { /// 3. The isolate is the first in the list of isolates on the VM. Future get _detectMainIsolate async { final isolateRefs = (await getVM()).isolates!; - final isolateCandidates = - await Future.wait<({IsolateRef ref, Isolate isolate})>( - isolateRefs.map( - (ref) async => (ref: ref, isolate: await getIsolate(ref.id!)), - ), - ); + final isolateCandidates = await isolateRefs + .map((ref) async => (ref: ref, isolate: await getIsolate(ref.id!))) + .wait; Isolate? mainIsolate; for (final isolate in isolateCandidates) { diff --git a/packages/devtools_shared/lib/src/test/cli_test_driver.dart b/packages/devtools_shared/lib/src/test/cli_test_driver.dart index e4c93c48194..d80e001048d 100644 --- a/packages/devtools_shared/lib/src/test/cli_test_driver.dart +++ b/packages/devtools_shared/lib/src/test/cli_test_driver.dart @@ -8,6 +8,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:collection/collection.dart'; import 'package:vm_service/utils.dart'; import 'package:vm_service/vm_service.dart'; import 'package:vm_service/vm_service_io.dart'; @@ -164,24 +165,21 @@ class CliAppFixture extends AppFixture { await waitFor(() async { const skipId = 'skip'; final vm = await serviceConnection.getVM(); - final List isolates = await Future.wait( - vm.isolates!.map( - (ref) => serviceConnection - .getIsolate(ref.id!) - // Calling getIsolate() can sometimes return a collected sentinel - // for an isolate that hasn't started yet. We can just ignore these - // as on the next trip around the Isolate will be returned. - // https://github.com/dart-lang/sdk/issues/33747 - .catchError((Object error) { - print('getIsolate(${ref.id}) failed, skipping\n$error'); - return Future.value(Isolate(id: skipId)); - }), - ), - ); - foundIsolate = isolates.firstWhere( + final isolates = await vm.isolates! + .map((ref) => serviceConnection + .getIsolate(ref.id!) + // Calling getIsolate() can sometimes return a collected sentinel + // for an isolate that hasn't started yet. We can just ignore these + // as on the next trip around the Isolate will be returned. + // https://github.com/dart-lang/sdk/issues/33747 + .catchError((Object error) { + print('getIsolate(${ref.id}) failed, skipping\n$error'); + return Future.value(Isolate(id: skipId)); + })) + .wait; + foundIsolate = isolates.firstWhereOrNull( (isolate) => - isolate!.id != skipId && isolate.pauseEvent?.kind == pauseEventKind, - orElse: () => null, + isolate.id != skipId && isolate.pauseEvent?.kind == pauseEventKind, ); return foundIsolate != null; }); diff --git a/packages/devtools_shared/lib/src/test/io_utils.dart b/packages/devtools_shared/lib/src/test/io_utils.dart index bb65050d584..1baf02854ec 100644 --- a/packages/devtools_shared/lib/src/test/io_utils.dart +++ b/packages/devtools_shared/lib/src/test/io_utils.dart @@ -64,11 +64,11 @@ mixin IOMixin { } Future cancelAllStreamSubscriptions() async { - await Future.wait(streamSubscriptions.map((s) => s.cancel())); - await Future.wait([ + await streamSubscriptions.map((s) => s.cancel()).wait; + await [ stdoutController.close(), stderrController.close(), - ]); + ].wait; streamSubscriptions.clear(); } diff --git a/packages/devtools_test/lib/src/helpers/utils.dart b/packages/devtools_test/lib/src/helpers/utils.dart index dad685272f8..4c2cb1ce052 100644 --- a/packages/devtools_test/lib/src/helpers/utils.dart +++ b/packages/devtools_test/lib/src/helpers/utils.dart @@ -189,7 +189,7 @@ Future loadFonts() async { await loader.load(); }); - await Future.wait(loadFontsFuture); + await loadFontsFuture.wait; } void verifyIsSearchMatch(