Reformat all code with recent Flutter/Dart SDK (#9871)
diff --git a/packages/devtools_app_shared/example/service_example.dart b/packages/devtools_app_shared/example/service_example.dart index 95c7e8c..aec00ae 100644 --- a/packages/devtools_app_shared/example/service_example.dart +++ b/packages/devtools_app_shared/example/service_example.dart
@@ -40,10 +40,8 @@ ); /// Example: Get a service extension state. - final performanceOverlayEnabled = - serviceManager.serviceExtensionManager.getServiceExtensionState( - extensions.performanceOverlay.extension, - ); + final performanceOverlayEnabled = serviceManager.serviceExtensionManager + .getServiceExtensionState(extensions.performanceOverlay.extension); // Example: Set a service extension state. await serviceManager.serviceExtensionManager.setServiceExtensionState(
diff --git a/packages/devtools_app_shared/example/ui/split_example.dart b/packages/devtools_app_shared/example/ui/split_example.dart index ef3f832..71ff8cd 100644 --- a/packages/devtools_app_shared/example/ui/split_example.dart +++ b/packages/devtools_app_shared/example/ui/split_example.dart
@@ -20,10 +20,7 @@ axis: Axis.horizontal, initialFractions: const [0.3, 0.7], minSizes: const [50.0, 100.0], - children: const [ - Text('Left side'), - Text('Right side'), - ], + children: const [Text('Left side'), Text('Right side')], ); } } @@ -42,15 +39,8 @@ axis: Axis.vertical, initialFractions: const [0.3, 0.3, 0.4], minSizes: const [50.0, 50.0, 100.0], - splitters: const [ - CustomSplitter(), - CustomSplitter(), - ], - children: const [ - Text('Top'), - Text('Middle'), - Text('Bottom'), - ], + splitters: const [CustomSplitter(), CustomSplitter()], + children: const [Text('Top'), Text('Middle'), Text('Bottom')], ); } } @@ -62,10 +52,7 @@ @override Widget build(BuildContext context) { - return const SizedBox( - height: _size, - child: Icon(Icons.front_hand), - ); + return const SizedBox(height: _size, child: Icon(Icons.front_hand)); } @override
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 39f1fc2..5c926ef 100644 --- a/packages/devtools_app_shared/lib/src/service/connected_app.dart +++ b/packages/devtools_app_shared/lib/src/service/connected_app.dart
@@ -52,8 +52,8 @@ String? _operatingSystem; // TODO(kenz): investigate if we can use `libraryUriAvailableNow` instead. - Future<bool> get isFlutterApp async => _isFlutterApp ??= - await serviceManager!.libraryUriAvailable(flutterLibraryUri); + Future<bool> get isFlutterApp async => _isFlutterApp ??= await serviceManager! + .libraryUriAvailable(flutterLibraryUri); bool? get isFlutterAppNow { assert(_isFlutterApp != null); @@ -85,8 +85,8 @@ bool? _isProfileBuild; // TODO(kenz): investigate if we can use `libraryUriAvailableNow` instead. - Future<bool> get isDartWebApp async => _isDartWebApp ??= - await serviceManager!.libraryUriAvailable(dartHtmlLibraryUri); + Future<bool> get isDartWebApp async => _isDartWebApp ??= await serviceManager! + .libraryUriAvailable(dartHtmlLibraryUri); bool? get isDartWebAppNow { assert(_isDartWebApp != null); @@ -189,14 +189,14 @@ } Map<String, Object?> toJson() => { - isFlutterAppKey: isFlutterAppNow, - isProfileBuildKey: isProfileBuildNow, - isDartWebAppKey: isDartWebAppNow, - isRunningOnDartVMKey: isRunningOnDartVM, - operatingSystemKey: operatingSystem, - if (flutterVersionNow != null && !flutterVersionNow!.unknown) - flutterVersionKey: flutterVersionNow!.version, - }; + isFlutterAppKey: isFlutterAppNow, + isProfileBuildKey: isProfileBuildNow, + isDartWebAppKey: isDartWebAppNow, + isRunningOnDartVMKey: isRunningOnDartVM, + operatingSystemKey: operatingSystem, + if (flutterVersionNow != null && !flutterVersionNow!.unknown) + flutterVersionKey: flutterVersionNow!.version, + }; } final class OfflineConnectedApp extends ConnectedApp { @@ -215,7 +215,8 @@ isProfileBuildNow: json[ConnectedApp.isProfileBuildKey] as bool?, isDartWebAppNow: json[ConnectedApp.isDartWebAppKey] as bool?, isRunningOnDartVM: json[ConnectedApp.isRunningOnDartVMKey] as bool?, - operatingSystem: (json[ConnectedApp.operatingSystemKey] as String?) ?? + operatingSystem: + (json[ConnectedApp.operatingSystemKey] as String?) ?? ConnectedApp.unknownOS, ); }
diff --git a/packages/devtools_app_shared/lib/src/service/dtd_manager.dart b/packages/devtools_app_shared/lib/src/service/dtd_manager.dart index 83f9970..9f78fdd 100644 --- a/packages/devtools_app_shared/lib/src/service/dtd_manager.dart +++ b/packages/devtools_app_shared/lib/src/service/dtd_manager.dart
@@ -25,8 +25,9 @@ /// The current state of the connection. ValueListenable<DTDConnectionState> get connectionState => _connectionState; - final _connectionState = - ValueNotifier<DTDConnectionState>(NotConnectedDTDState()); + final _connectionState = ValueNotifier<DTDConnectionState>( + NotConnectedDTDState(), + ); /// The URI of the current DTD connection. Uri? get uri => _uri; @@ -77,13 +78,15 @@ // // If this happens, just disconnect (without disabling reconnect) so the // done event fires and then the usual handling occurs. - _periodicConnectionCheck = - Timer.periodic(_periodicConnectionCheckInterval, (timer) async { - if (_dtd.isClosed) { - _log.warning('The DTD connection has dropped'); - await disconnectImpl(allowReconnect: true); - } - }); + _periodicConnectionCheck = Timer.periodic( + _periodicConnectionCheckInterval, + (timer) async { + if (_dtd.isClosed) { + _log.warning('The DTD connection has dropped'); + await disconnectImpl(allowReconnect: true); + } + }, + ); return dtd; } @@ -182,12 +185,16 @@ // If a connection drops (and we hadn't disabled auto-reconnect, such // as by explicitly calling disconnect/dispose), we should attempt to // reconnect. - unawaited(connection.done - .then((_) => _reconnectAfterDroppedConnection(uri, onError: onError)) - .catchError((_) { - // TODO(dantup): Create a devtools_app_shared version of safeUnawaited. - // https://github.com/flutter/devtools/pull/9587#discussion_r2624306047 - })); + unawaited( + connection.done + .then( + (_) => _reconnectAfterDroppedConnection(uri, onError: onError), + ) + .catchError((_) { + // TODO(dantup): Create a devtools_app_shared version of safeUnawaited. + // https://github.com/flutter/devtools/pull/9587#discussion_r2624306047 + }), + ); } catch (e, st) { onError?.call(e, st); } @@ -229,8 +236,8 @@ }) { // On explicit connections, we capture the connect function so that we // can call it again if [reconnect()] is called. - final connectFunc = _lastConnectFunc = - () => _connectImpl(uri, onError: onError, maxRetries: maxRetries); + final connectFunc = _lastConnectFunc = () => + _connectImpl(uri, onError: onError, maxRetries: maxRetries); return connectFunc(); } @@ -284,15 +291,18 @@ /// Listens for service registration events on the [dtd] connection. Future<void> _listenForServiceRegistrationEvents( - DartToolingDaemon dtd) async { + DartToolingDaemon dtd, + ) async { // We immediately begin listening for service registration events on the new // DTD connection before canceling the previous subscription. This // guarantees that we don't miss any events across reconnects. // ignore: cancel_subscriptions, false positive, it is canceled below. final nextServiceRegistrationSubscription = dtd .onEvent(CoreDtdServiceConstants.servicesStreamId) - .listen(_forwardServiceRegistrationEvents, - onError: _logServiceStreamError); + .listen( + _forwardServiceRegistrationEvents, + onError: _logServiceStreamError, + ); await dtd.streamListen(CoreDtdServiceConstants.servicesStreamId); // Cancel the previous subscription. @@ -307,7 +317,7 @@ final kind = event.kind; final isRegistrationEvent = kind == CoreDtdServiceConstants.serviceRegisteredKind || - kind == CoreDtdServiceConstants.serviceUnregisteredKind; + kind == CoreDtdServiceConstants.serviceUnregisteredKind; if (isRegistrationEvent) { _serviceRegistrationController.add(event);
diff --git a/packages/devtools_app_shared/lib/src/service/eval_on_dart_library.dart b/packages/devtools_app_shared/lib/src/service/eval_on_dart_library.dart index 0fbe004..3de4f86 100644 --- a/packages/devtools_app_shared/lib/src/service/eval_on_dart_library.dart +++ b/packages/devtools_app_shared/lib/src/service/eval_on_dart_library.dart
@@ -105,8 +105,9 @@ } try { - final isolate = - await serviceManager.isolateManager.isolateState(isolateRef).isolate; + final isolate = await serviceManager.isolateManager + .isolateState(isolateRef) + .isolate; if (_currentRequestId != requestId) { // The initialize request is obsolete. return; @@ -150,11 +151,7 @@ } return await addRequest<InstanceRef?>( isAlive, - () => _eval( - expression, - scope: scope, - shouldLogError: shouldLogError, - ), + () => _eval(expression, scope: scope, shouldLogError: shouldLogError), ); } @@ -626,12 +623,14 @@ int? count, }) { return addRequest<T>(isAlive, () async { - final T value = await service.getObject( - _isolateRef!.id!, - instance.id!, - offset: offset, - count: count, - ) as T; + final T value = + await service.getObject( + _isolateRef!.id!, + instance.id!, + offset: offset, + count: count, + ) + as T; return value; }); }
diff --git a/packages/devtools_app_shared/lib/src/service/flutter_version.dart b/packages/devtools_app_shared/lib/src/service/flutter_version.dart index 5e41454..af02f82 100644 --- a/packages/devtools_app_shared/lib/src/service/flutter_version.dart +++ b/packages/devtools_app_shared/lib/src/service/flutter_version.dart
@@ -94,14 +94,14 @@ @override int get hashCode => Object.hash( - version, - channel, - repositoryUrl, - frameworkRevision, - frameworkCommitDate, - engineRevision, - dartSdkVersion, - ); + version, + channel, + repositoryUrl, + frameworkRevision, + frameworkCommitDate, + engineRevision, + dartSdkVersion, + ); static final _stableVersionRegex = RegExp(r'^\d+\.\d+\.\d+$'); static final _isNumericRegex = RegExp(r'\d');
diff --git a/packages/devtools_app_shared/lib/src/service/isolate_state.dart b/packages/devtools_app_shared/lib/src/service/isolate_state.dart index 3376476..d08e05e 100644 --- a/packages/devtools_app_shared/lib/src/service/isolate_state.dart +++ b/packages/devtools_app_shared/lib/src/service/isolate_state.dart
@@ -34,7 +34,8 @@ void handleIsolateLoad(Isolate isolate) { _isolateNow = isolate; - _isPaused.value = isolate.pauseEvent != null && + _isPaused.value = + isolate.pauseEvent != null && isolate.pauseEvent!.kind != EventKind.kResume; rootInfo = RootInfo(_isolateNow!.rootLib?.uri);
diff --git a/packages/devtools_app_shared/lib/src/service/resolved_uri_manager.dart b/packages/devtools_app_shared/lib/src/service/resolved_uri_manager.dart index aaed614..1de7b81 100644 --- a/packages/devtools_app_shared/lib/src/service/resolved_uri_manager.dart +++ b/packages/devtools_app_shared/lib/src/service/resolved_uri_manager.dart
@@ -31,8 +31,10 @@ Future<void> fetchPackageUris(String isolateId, List<String> uris) async { if (uris.isEmpty) return; if (_packagePathMappings != null) { - final packageUris = - (await _service!.lookupPackageUris(isolateId, uris)).uris; + final packageUris = (await _service!.lookupPackageUris( + isolateId, + uris, + )).uris; if (packageUris != null) { _packagePathMappings!.addMappings( @@ -54,9 +56,10 @@ /// * [packageUris] - List of URIs to fetch full file paths for. Future<void> fetchFileUris(String isolateId, List<String> packageUris) async { if (_packagePathMappings != null) { - final fileUris = - (await _service!.lookupResolvedPackageUris(isolateId, packageUris)) - .uris; + final fileUris = (await _service!.lookupResolvedPackageUris( + isolateId, + packageUris, + )).uris; // [_packagePathMappings] could have been set to null during the async gap // so check that it is non-null again here. @@ -95,15 +98,11 @@ String? lookupPackageToFullPathMapping( String isolateId, String packagePath, - ) => - _isolatePackageToFullPathMappings[isolateId]?[packagePath]; + ) => _isolatePackageToFullPathMappings[isolateId]?[packagePath]; /// Returns the full path to package path mapping if it has already /// been fetched. - String? lookupFullPathToPackageMapping( - String isolateId, - String fullPath, - ) => + String? lookupFullPathToPackageMapping(String isolateId, String fullPath) => _isolateFullPathToPackageMappings[isolateId]?[fullPath]; /// Saves the mappings of [fullPaths] to [packagePaths]. @@ -118,16 +117,10 @@ required List<String?> packagePaths, }) { assert(fullPaths.length == packagePaths.length); - final fullPathToPackageMappings = - _isolateFullPathToPackageMappings.putIfAbsent( - isolateId, - () => <String, String?>{}, - ); - final packageToFullPathMappings = - _isolatePackageToFullPathMappings.putIfAbsent( - isolateId, - () => <String, String?>{}, - ); + final fullPathToPackageMappings = _isolateFullPathToPackageMappings + .putIfAbsent(isolateId, () => <String, String?>{}); + final packageToFullPathMappings = _isolatePackageToFullPathMappings + .putIfAbsent(isolateId, () => <String, String?>{}); assert(fullPaths.length == packagePaths.length);
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 7e1eda1..a76f8b0 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
@@ -148,7 +148,7 @@ _pendingServiceExtensions.clear(); await [ for (final extension in extensionsToProcess) - _addServiceExtension(extension) + _addServiceExtension(extension), ].wait; } @@ -184,11 +184,12 @@ } await [ for (final extension in extensionRpcs) - _maybeAddServiceExtension(extension) + _maybeAddServiceExtension(extension), ].wait; } else { await [ - for (final extension in extensionRpcs) _addServiceExtension(extension) + for (final extension in extensionRpcs) + _addServiceExtension(extension), ].wait; } } @@ -489,10 +490,8 @@ _performActionAndClearMap( _serviceExtensionStates, - action: (state) => state.value = ServiceExtensionState( - enabled: false, - value: null, - ), + action: (state) => + state.value = ServiceExtensionState(enabled: false, value: null), ); } @@ -572,21 +571,15 @@ } ValueNotifier<ServiceExtensionState> _serviceExtensionState(String name) { - return _serviceExtensionStates.putIfAbsent( - name, - () { - final state = _enabledServiceExtensions[name]; - return ValueNotifier( - state ?? ServiceExtensionState(enabled: false, value: null), - ); - }, - ); + return _serviceExtensionStates.putIfAbsent(name, () { + final state = _enabledServiceExtensions[name]; + return ValueNotifier( + state ?? ServiceExtensionState(enabled: false, value: null), + ); + }); } - void vmServiceOpened( - VmService service, - ConnectedApp connectedApp, - ) async { + void vmServiceOpened(VmService service, ConnectedApp connectedApp) async { _checkForFirstFrameStarted = false; cancelStreamSubscriptions(); cancelListeners(); @@ -610,8 +603,9 @@ final mainIsolateRef = _isolateManager.mainIsolate.value; if (mainIsolateRef != null) { _checkForFirstFrameStarted = false; - final mainIsolate = - await _isolateManager.isolateState(mainIsolateRef).isolate; + final mainIsolate = await _isolateManager + .isolateState(mainIsolateRef) + .isolate; if (mainIsolate != null) { await _registerMainIsolate(mainIsolate, mainIsolateRef); } @@ -638,10 +632,7 @@ } @override - int get hashCode => Object.hash( - enabled, - value, - ); + int get hashCode => Object.hash(enabled, value); @override String toString() {
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 8745c2c..da70413 100644 --- a/packages/devtools_app_shared/lib/src/service/service_manager.dart +++ b/packages/devtools_app_shared/lib/src/service/service_manager.dart
@@ -49,9 +49,7 @@ afterCloseVmService, } -enum ServiceManagerOverride { - initIsolates, -} +enum ServiceManagerOverride { initIsolates } // TODO(kenz): add an offline service manager implementation. // TODO(https://github.com/flutter/devtools/issues/6239): try to remove this. @@ -149,8 +147,9 @@ ValueListenable<ConnectedState> get connectedState => _connectedState; - final _connectedState = - ValueNotifier<ConnectedState>(const ConnectedState(false)); + final _connectedState = ValueNotifier<ConnectedState>( + const ConnectedState(false), + ); final _deviceBusy = ValueNotifier<bool>(false); @@ -210,10 +209,7 @@ ServiceManagerCallback<T> callback, ) { _lifecycleCallbacks - .putIfAbsent( - lifecycle, - () => <ServiceManagerCallback<T>>[], - ) + .putIfAbsent(lifecycle, () => <ServiceManagerCallback<T>>[]) .add(callback); } @@ -319,9 +315,7 @@ try { await vmService.setFlag('pause_isolates_on_start', 'true'); - await vmService.requirePermissionToResume( - onPauseStart: true, - ); + await vmService.requirePermissionToResume(onPauseStart: true); } catch (error) { _log.warning('$error'); } @@ -433,8 +427,10 @@ Future<void> manuallyDisconnect() async { if (connectedState.value.connected) { await vmServiceClosed( - connectionState: - const ConnectedState(false, userInitiatedConnectionState: true), + connectionState: const ConnectedState( + false, + userInitiatedConnectionState: true, + ), ); } } @@ -475,9 +471,7 @@ } Future<Response> get flutterVersion async { - return await callServiceOnMainIsolate( - flutterVersionService.service, - ); + return await callServiceOnMainIsolate(flutterVersionService.service); } /// This can throw an [RPCError]. @@ -513,8 +507,9 @@ /// running the test runner, and not the test library itself, so we have to do /// some extra work to find the package root of the test target. Future<Uri?> connectedAppPackageRoot(DTDManager dtdManager) async { - var packageRootUriString = - await rootPackageDirectoryForMainIsolate(dtdManager); + var packageRootUriString = await rootPackageDirectoryForMainIsolate( + dtdManager, + ); _log.fine( '[connectedAppPackageRoot] root package directory for main isolate: ' '$packageRootUriString', @@ -525,14 +520,12 @@ if (packageRootUriString?.endsWith('.dart') ?? false) { final rootLibrary = await _mainIsolateRootLibrary(); if (rootLibrary != null) { - packageRootUriString = (await _lookupPackageRootByEval(rootLibrary)) ?? + packageRootUriString = + (await _lookupPackageRootByEval(rootLibrary)) ?? // TODO(kenz): remove this fallback once all test bootstrap // generators include the `packageConfigLocation` constant we // can evaluate. - await _lookupPackageRootByImportPrefix( - rootLibrary, - dtdManager, - ); + await _lookupPackageRootByImportPrefix(rootLibrary, dtdManager); } } _log.fine( @@ -559,14 +552,15 @@ final packageConfig = (await eval.evalInstance( 'packageConfigLocation', isAlive: evalDisposable, - )) - .valueAsString; + )).valueAsString; // TODO(https://github.com/flutter/devtools/issues/7944): return the // unmodified package config location. For this case, be sure to handle // invalid values like the empty String or 'null'. - final packageConfigIdentifier = - path.join('.dart_tool', 'package_config.json'); + final packageConfigIdentifier = path.join( + '.dart_tool', + 'package_config.json', + ); if (packageConfig?.endsWith(packageConfigIdentifier) ?? false) { _log.fine( '[connectedAppPackageRoot] detected test package config from root '
diff --git a/packages/devtools_app_shared/lib/src/ui/buttons.dart b/packages/devtools_app_shared/lib/src/ui/buttons.dart index 9fe9534..c726cac 100644 --- a/packages/devtools_app_shared/lib/src/ui/buttons.dart +++ b/packages/devtools_app_shared/lib/src/ui/buttons.dart
@@ -25,9 +25,9 @@ this.outlined = true, this.tooltipPadding, }) : assert( - label != null || icon != null, - 'Either icon or label must be specified.', - ); + label != null || icon != null, + 'Either icon or label must be specified.', + ); factory DevToolsButton.iconOnly({ required IconData icon, @@ -92,8 +92,9 @@ final colorScheme = Theme.of(context).colorScheme; var textColor = color; if (textColor == null && elevated) { - textColor = - onPressed == null ? colorScheme.onSurface : colorScheme.onPrimary; + textColor = onPressed == null + ? colorScheme.onSurface + : colorScheme.onPrimary; } final iconLabel = MaterialIconLabel( label: label!, @@ -116,10 +117,7 @@ child: maybeWrapWithTooltip( tooltip: tooltip, tooltipPadding: tooltipPadding, - child: ElevatedButton( - onPressed: onPressed, - child: iconLabel, - ), + child: ElevatedButton(onPressed: onPressed, child: iconLabel), ), ); } @@ -239,8 +237,9 @@ Widget build(BuildContext context) { final theme = Theme.of(context); return DevToolsToggleButtonGroup( - borderColor: - outlined || isSelected ? theme.focusColor : Colors.transparent, + borderColor: outlined || isSelected + ? theme.focusColor + : Colors.transparent, selectedStates: [isSelected], onPressed: (_) => onPressed(), fillColor: fillColor, @@ -291,9 +290,7 @@ button = Container( decoration: BoxDecoration( border: Border( - left: BorderSide( - color: Theme.of(context).focusColor, - ), + left: BorderSide(color: Theme.of(context).focusColor), ), ), child: button, @@ -306,9 +303,7 @@ height: defaultButtonHeight, child: RoundedOutlinedBorder( child: Row( - children: [ - for (int i = 0; i < items.length; i++) buildButton(i), - ], + children: [for (int i = 0; i < items.length; i++) buildButton(i)], ), ), ); @@ -366,15 +361,15 @@ String? tooltip, this.onPressed, this.autofocus = false, - }) : tooltip = tooltip ?? label, - assert( - label != null || icon != null || iconAsset != null, - 'At least one of icon, iconAsset, or label must be specified.', - ), - assert( - icon == null || iconAsset == null, - 'Only one of icon and iconAsset may be specified.', - ); + }) : tooltip = tooltip ?? label, + assert( + label != null || icon != null || iconAsset != null, + 'At least one of icon, iconAsset, or label must be specified.', + ), + assert( + icon == null || iconAsset == null, + 'Only one of icon and iconAsset may be specified.', + ); final String? label; final IconData? icon;
diff --git a/packages/devtools_app_shared/lib/src/ui/common.dart b/packages/devtools_app_shared/lib/src/ui/common.dart index 90b196e..f27a29c 100644 --- a/packages/devtools_app_shared/lib/src/ui/common.dart +++ b/packages/devtools_app_shared/lib/src/ui/common.dart
@@ -34,9 +34,7 @@ crossAxisAlignment: CrossAxisAlignment.stretch, children: [ header, - Expanded( - child: child, - ), + Expanded(child: child), ], ), ); @@ -94,7 +92,8 @@ Widget build(BuildContext context) { final theme = Theme.of(context); final borderSide = defaultBorderSide(theme); - final decoration = !roundedTopBorder && + final decoration = + !roundedTopBorder && (includeTopBorder || includeBottomBorder || includeLeftBorder || @@ -130,10 +129,7 @@ if (roundedTopBorder) { container = RoundedOutlinedBorder.onlyTop(child: container); } - return SizedBox.fromSize( - size: preferredSize, - child: container, - ); + return SizedBox.fromSize(size: preferredSize, child: container); } @override @@ -183,24 +179,22 @@ factory RoundedOutlinedBorder.onlyTop({ required Widget? child, bool clip = false, - }) => - RoundedOutlinedBorder( - showBottomLeft: false, - showBottomRight: false, - clip: clip, - child: child, - ); + }) => RoundedOutlinedBorder( + showBottomLeft: false, + showBottomRight: false, + clip: clip, + child: child, + ); factory RoundedOutlinedBorder.onlyBottom({ required Widget? child, bool clip = false, - }) => - RoundedOutlinedBorder( - showTopLeft: false, - showTopRight: false, - clip: clip, - child: child, - ); + }) => RoundedOutlinedBorder( + showTopLeft: false, + showTopRight: false, + clip: clip, + child: child, + ); final bool showTopLeft; final bool showTopRight; @@ -326,22 +320,19 @@ }); const PaddedDivider.thin({super.key}) - : padding = const EdgeInsets.only(bottom: 4.0); + : padding = const EdgeInsets.only(bottom: 4.0); const PaddedDivider.noPadding({super.key}) : padding = EdgeInsets.zero; PaddedDivider.vertical({super.key, double padding = densePadding}) - : padding = EdgeInsets.symmetric(vertical: padding); + : padding = EdgeInsets.symmetric(vertical: padding); /// The padding to place around the divider. final EdgeInsets padding; @override Widget build(BuildContext context) { - return Padding( - padding: padding, - child: const Divider(thickness: 1.0), - ); + return Padding(padding: padding, child: const Divider(thickness: 1.0)); } } @@ -416,10 +407,7 @@ icon, // TODO(jacobr): animate showing and hiding the text. if (isScreenWiderThan(context, unscaledMinIncludeTextWidth)) - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: Text(text), - ), + Padding(padding: const EdgeInsets.only(left: 8.0), child: Text(text)), ], ); } @@ -434,14 +422,14 @@ this.iconSize, this.color, this.minScreenWidthForText, - }) : assert( - label != null || iconData != null || iconAsset != null, - 'At least one of iconData, iconAsset, or label must be specified.', - ), - assert( - iconData == null || iconAsset == null, - 'Only one of iconData and iconAsset may be specified.', - ); + }) : assert( + label != null || iconData != null || iconAsset != null, + 'At least one of iconData, iconAsset, or label must be specified.', + ), + assert( + iconData == null || iconAsset == null, + 'Only one of iconData and iconAsset may be specified.', + ); final IconData? iconData; final String? iconAsset; @@ -520,8 +508,9 @@ return SelectionArea( child: Text( json != null ? encoder.convert(json) : formattedString!, - style: - useSubtleStyle ? theme.subtleFixedFontStyle : theme.fixedFontStyle, + style: useSubtleStyle + ? theme.subtleFixedFontStyle + : theme.fixedFontStyle, ), ); } @@ -530,8 +519,8 @@ /// An extension on [ScrollController] to facilitate having the scrolling widget /// auto scroll to the bottom on new content. extension ScrollControllerAutoScroll on ScrollController { -// TODO(devoncarew): We lose dock-to-bottom when we receive content when we're -// off screen. + // TODO(devoncarew): We lose dock-to-bottom when we receive content when we're + // off screen. /// Return whether the view is currently scrolled to the bottom. bool get atScrollBottom { @@ -575,14 +564,14 @@ VoidCallback? onLaunchUrlError, TextStyle? style, }) : super( - text: link.display, - style: style ?? Theme.of(context).linkTextStyle, - recognizer: TapGestureRecognizer() - ..onTap = () async { - onTap?.call(); - await launchUrl(link.url, onError: onLaunchUrlError); - }, - ); + text: link.display, + style: style ?? Theme.of(context).linkTextStyle, + recognizer: TapGestureRecognizer() + ..onTap = () async { + onTap?.call(); + await launchUrl(link.url, onError: onLaunchUrlError); + }, + ); } /// A data model for a clickable link in a UI. @@ -647,9 +636,10 @@ overflow: TextOverflow.clip, softWrap: false, style: theme.regularTextStyle.copyWith( - color: textColor ?? colorScheme.onSecondary, - backgroundColor: backgroundColor ?? colorScheme.secondary, - fontSize: fontSize ?? defaultFontSize), + color: textColor ?? colorScheme.onSecondary, + backgroundColor: backgroundColor ?? colorScheme.secondary, + fontSize: fontSize ?? defaultFontSize, + ), ), ); return tooltipText != null
diff --git a/packages/devtools_app_shared/lib/src/ui/dialogs.dart b/packages/devtools_app_shared/lib/src/ui/dialogs.dart index 07c46ff..8eb9162 100644 --- a/packages/devtools_app_shared/lib/src/ui/dialogs.dart +++ b/packages/devtools_app_shared/lib/src/ui/dialogs.dart
@@ -189,10 +189,7 @@ @override Widget build(BuildContext context) { - return Text( - helpText, - style: textStyle(context), - ); + return Text(helpText, style: textStyle(context)); } } @@ -260,10 +257,7 @@ @override Widget build(BuildContext context) { - return TextButton( - onPressed: onPressed, - child: child, - ); + return TextButton(onPressed: onPressed, child: child); } } @@ -280,12 +274,10 @@ title: DialogTitleText(title), includeDivider: false, content: content, - actionsAlignment: - actions.isNotEmpty ? MainAxisAlignment.spaceBetween : null, - actions: [ - ...actions, - const DialogCloseButton(), - ], + actionsAlignment: actions.isNotEmpty + ? MainAxisAlignment.spaceBetween + : null, + actions: [...actions, const DialogCloseButton()], ), ), );
diff --git a/packages/devtools_app_shared/lib/src/ui/flex_split_column.dart b/packages/devtools_app_shared/lib/src/ui/flex_split_column.dart index 5b39be9..ee7cc76 100644 --- a/packages/devtools_app_shared/lib/src/ui/flex_split_column.dart +++ b/packages/devtools_app_shared/lib/src/ui/flex_split_column.dart
@@ -32,17 +32,17 @@ required List<Widget> children, required List<double> initialFractions, required List<double> minSizes, - }) : assert(children.length >= 2), - assert(initialFractions.length >= 2), - assert(children.length == initialFractions.length), - assert(minSizes.length == children.length), - _children = buildChildrenWithFirstHeader(children, headers), - _initialFractions = modifyInitialFractionsToIncludeFirstHeader( - initialFractions, - headers, - totalHeight, - ), - _minSizes = modifyMinSizesToIncludeFirstHeader(minSizes, headers); + }) : assert(children.length >= 2), + assert(initialFractions.length >= 2), + assert(children.length == initialFractions.length), + assert(minSizes.length == children.length), + _children = buildChildrenWithFirstHeader(children, headers), + _initialFractions = modifyInitialFractionsToIncludeFirstHeader( + initialFractions, + headers, + totalHeight, + ), + _minSizes = modifyMinSizesToIncludeFirstHeader(minSizes, headers); /// The headers that will be laid out above each corresponding child in /// `children`.
diff --git a/packages/devtools_app_shared/lib/src/ui/icons.dart b/packages/devtools_app_shared/lib/src/ui/icons.dart index 977cb95..4661641 100644 --- a/packages/devtools_app_shared/lib/src/ui/icons.dart +++ b/packages/devtools_app_shared/lib/src/ui/icons.dart
@@ -9,13 +9,17 @@ /// A widget that renders either an [icon] from a font glyph or an [iconAsset] /// from the app bundle. final class DevToolsIcon extends StatelessWidget { - const DevToolsIcon( - {super.key, this.icon, this.iconAsset, this.color, double? size}) - : assert( - (icon == null) != (iconAsset == null), - 'Exactly one of icon and iconAsset must be specified.', - ), - size = size ?? defaultIconSize; + const DevToolsIcon({ + super.key, + this.icon, + this.iconAsset, + this.color, + double? size, + }) : assert( + (icon == null) != (iconAsset == null), + 'Exactly one of icon and iconAsset must be specified.', + ), + size = size ?? defaultIconSize; /// The icon to use for this screen's tab. /// @@ -53,8 +57,8 @@ this.color, double? height, double? width, - }) : _width = width, - _height = height; + }) : _width = width, + _height = height; final String asset; final Color? color;
diff --git a/packages/devtools_app_shared/lib/src/ui/split_pane.dart b/packages/devtools_app_shared/lib/src/ui/split_pane.dart index 4bda05e..d68a2e6 100644 --- a/packages/devtools_app_shared/lib/src/ui/split_pane.dart +++ b/packages/devtools_app_shared/lib/src/ui/split_pane.dart
@@ -29,9 +29,9 @@ required this.initialFractions, this.minSizes, this.splitters, - }) : assert(children.length >= 2), - assert(initialFractions.length >= 2), - assert(children.length == initialFractions.length) { + }) : assert(children.length >= 2), + assert(initialFractions.length >= 2), + assert(children.length == initialFractions.length) { _verifyFractionsSumTo1(initialFractions); if (minSizes != null) { assert(minSizes!.length == children.length); @@ -142,8 +142,10 @@ minSizeForIndex(index) / availableSize; void clampFraction(int index) { - fractions[index] = - fractions[index].clamp(minFractionForIndex(index), 1.0); + fractions[index] = fractions[index].clamp( + minFractionForIndex(index), + 1.0, + ); } double sizeForIndex(int index) => availableSize * fractions[index]; @@ -190,8 +192,9 @@ final sizes = List.generate(fractions.length, (i) => sizeForIndex(i)); void updateSpacing(DragUpdateDetails dragDetails, int splitterIndex) { - final dragDelta = - isHorizontal ? dragDetails.delta.dx : dragDetails.delta.dy; + final dragDelta = isHorizontal + ? dragDetails.delta.dx + : dragDetails.delta.dy; final fractionalDelta = dragDelta / axisSize; // Returns the actual delta applied to elements before the splitter. @@ -241,12 +244,14 @@ // the shrinking children first so that we do not over-increase the size // of the growing children and cause layout overflow errors. if (fractionalDelta <= 0.0) { - final appliedDelta = - updateSpacingBeforeSplitterIndex(fractionalDelta); + final appliedDelta = updateSpacingBeforeSplitterIndex( + fractionalDelta, + ); updateSpacingAfterSplitterIndex(-appliedDelta); } else { - final appliedDelta = - updateSpacingAfterSplitterIndex(-fractionalDelta); + final appliedDelta = updateSpacingAfterSplitterIndex( + -fractionalDelta, + ); updateSpacingBeforeSplitterIndex(-appliedDelta); } });
diff --git a/packages/devtools_app_shared/lib/src/ui/text_field.dart b/packages/devtools_app_shared/lib/src/ui/text_field.dart index eda5451..918963a 100644 --- a/packages/devtools_app_shared/lib/src/ui/text_field.dart +++ b/packages/devtools_app_shared/lib/src/ui/text_field.dart
@@ -36,8 +36,9 @@ /// This is the default border radius used by the [OutlineInputBorder] /// constructor. - static const _defaultInputBorderRadius = - BorderRadius.all(Radius.circular(4.0)); + static const _defaultInputBorderRadius = BorderRadius.all( + Radius.circular(4.0), + ); @override Widget build(BuildContext context) { @@ -151,30 +152,27 @@ factory InputDecorationSuffixButton.clear({ required VoidCallback? onPressed, - }) => - InputDecorationSuffixButton( - icon: Icons.clear, - onPressed: onPressed, - tooltip: 'Clear', - ); + }) => InputDecorationSuffixButton( + icon: Icons.clear, + onPressed: onPressed, + tooltip: 'Clear', + ); factory InputDecorationSuffixButton.close({ required VoidCallback? onPressed, - }) => - InputDecorationSuffixButton( - icon: Icons.close, - onPressed: onPressed, - tooltip: 'Close', - ); + }) => InputDecorationSuffixButton( + icon: Icons.close, + onPressed: onPressed, + tooltip: 'Close', + ); factory InputDecorationSuffixButton.help({ required VoidCallback? onPressed, - }) => - InputDecorationSuffixButton( - icon: Icons.question_mark, - onPressed: onPressed, - tooltip: 'Help', - ); + }) => InputDecorationSuffixButton( + icon: Icons.question_mark, + onPressed: onPressed, + tooltip: 'Help', + ); final IconData icon; final VoidCallback? onPressed;
diff --git a/packages/devtools_app_shared/lib/src/ui/theme/_ide_theme_web.dart b/packages/devtools_app_shared/lib/src/ui/theme/_ide_theme_web.dart index 7640fbd..4b55e70 100644 --- a/packages/devtools_app_shared/lib/src/ui/theme/_ide_theme_web.dart +++ b/packages/devtools_app_shared/lib/src/ui/theme/_ide_theme_web.dart
@@ -22,8 +22,9 @@ // If the environment has provided a background color, set it immediately // to avoid a white page until the first Flutter frame is rendered. if (overrides.backgroundColor != null) { - document.body!.style.backgroundColor = - toCssHexColor(overrides.backgroundColor!); + document.body!.style.backgroundColor = toCssHexColor( + overrides.backgroundColor!, + ); } return overrides;
diff --git a/packages/devtools_app_shared/lib/src/ui/theme/theme.dart b/packages/devtools_app_shared/lib/src/ui/theme/theme.dart index 0480cf3..cc3f080 100644 --- a/packages/devtools_app_shared/lib/src/ui/theme/theme.dart +++ b/packages/devtools_app_shared/lib/src/ui/theme/theme.dart
@@ -26,35 +26,23 @@ : _lightTheme(ideTheme: ideTheme, theme: theme); return colorTheme.copyWith( - primaryTextTheme: - theme.primaryTextTheme.merge(colorTheme.primaryTextTheme), - textTheme: theme.textTheme.merge(colorTheme.textTheme)); + primaryTextTheme: theme.primaryTextTheme.merge(colorTheme.primaryTextTheme), + textTheme: theme.textTheme.merge(colorTheme.textTheme), + ); } -ThemeData _darkTheme({ - required IdeTheme ideTheme, - required ThemeData theme, -}) { +ThemeData _darkTheme({required IdeTheme ideTheme, required ThemeData theme}) { final background = isValidDarkColor(ideTheme.backgroundColor) ? ideTheme.backgroundColor! : theme.colorScheme.surface; - return _baseTheme( - theme: theme, - backgroundColor: background, - ); + return _baseTheme(theme: theme, backgroundColor: background); } -ThemeData _lightTheme({ - required IdeTheme ideTheme, - required ThemeData theme, -}) { +ThemeData _lightTheme({required IdeTheme ideTheme, required ThemeData theme}) { final background = isValidLightColor(ideTheme.backgroundColor) ? ideTheme.backgroundColor! : theme.colorScheme.surface; - return _baseTheme( - theme: theme, - backgroundColor: background, - ); + return _baseTheme(theme: theme, backgroundColor: background); } ThemeData _baseTheme({ @@ -68,8 +56,9 @@ tabAlignment: TabAlignment.start, dividerColor: Colors.transparent, labelStyle: theme.regularTextStyle, - labelPadding: - const EdgeInsets.symmetric(horizontal: defaultTabBarPadding), + labelPadding: const EdgeInsets.symmetric( + horizontal: defaultTabBarPadding, + ), ), canvasColor: backgroundColor, scaffoldBackgroundColor: backgroundColor, @@ -110,17 +99,13 @@ fixedSize: const WidgetStatePropertyAll<Size>(Size.fromHeight(24.0)), ), ), - dropdownMenuTheme: DropdownMenuThemeData( - textStyle: theme.regularTextStyle, - ), + dropdownMenuTheme: DropdownMenuThemeData(textStyle: theme.regularTextStyle), progressIndicatorTheme: const ProgressIndicatorThemeData( linearMinHeight: defaultLinearProgressIndicatorHeight, ), primaryTextTheme: _devToolsTextTheme(theme, theme.primaryTextTheme), textTheme: _devToolsTextTheme(theme, theme.textTheme), - colorScheme: theme.colorScheme.copyWith( - surface: backgroundColor, - ), + colorScheme: theme.colorScheme.copyWith(surface: backgroundColor), ); } @@ -381,11 +366,8 @@ bool get isDarkTheme => brightness == Brightness.dark; TextStyle get regularTextStyle => fixBlurryText( - TextStyle( - color: colorScheme.onSurface, - fontSize: defaultFontSize, - ), - ); + TextStyle(color: colorScheme.onSurface, fontSize: defaultFontSize), + ); TextStyle regularTextStyleWithColor(Color? color, {Color? backgroundColor}) => regularTextStyle.copyWith(color: color, backgroundColor: backgroundColor); @@ -405,66 +387,58 @@ regularTextStyle.copyWith(color: colorScheme.subtleTextColor); TextStyle get fixedFontStyle => fixBlurryText( - regularTextStyle.copyWith( - fontFamily: 'RobotoMono', - // Slightly smaller for fixes font text since it will appear larger - // to begin with. - fontSize: defaultFontSize - 1, - ), - ); + regularTextStyle.copyWith( + fontFamily: 'RobotoMono', + // Slightly smaller for fixes font text since it will appear larger + // to begin with. + fontSize: defaultFontSize - 1, + ), + ); - TextStyle get subtleFixedFontStyle => fixedFontStyle.copyWith( - color: colorScheme.subtleTextColor, - ); + TextStyle get subtleFixedFontStyle => + fixedFontStyle.copyWith(color: colorScheme.subtleTextColor); TextStyle get selectedSubtleTextStyle => subtleTextStyle.copyWith(color: colorScheme.onSurface); - TextStyle get tooltipFixedFontStyle => fixedFontStyle.copyWith( - color: colorScheme.tooltipTextColor, - ); + TextStyle get tooltipFixedFontStyle => + fixedFontStyle.copyWith(color: colorScheme.tooltipTextColor); TextStyle get fixedFontLinkStyle => fixedFontStyle.copyWith( - color: colorScheme._devtoolsLink, - decoration: TextDecoration.underline, - ); + color: colorScheme._devtoolsLink, + decoration: TextDecoration.underline, + ); TextStyle get linkTextStyle => fixBlurryText( - TextStyle( - color: colorScheme._devtoolsLink, - decoration: TextDecoration.underline, - fontSize: defaultFontSize, - ), - ); + TextStyle( + color: colorScheme._devtoolsLink, + decoration: TextDecoration.underline, + fontSize: defaultFontSize, + ), + ); TextStyle get subtleChartTextStyle => fixBlurryText( - TextStyle( - color: colorScheme._chartSubtleColor, - fontSize: smallFontSize, - ), - ); + TextStyle(color: colorScheme._chartSubtleColor, fontSize: smallFontSize), + ); TextStyle get searchMatchHighlightStyle => fixBlurryText( - const TextStyle( - color: Colors.black, - backgroundColor: activeSearchMatchColor, - ), - ); + const TextStyle( + color: Colors.black, + backgroundColor: activeSearchMatchColor, + ), + ); TextStyle get searchMatchHighlightStyleFocused => fixBlurryText( - const TextStyle( - color: Colors.black, - backgroundColor: searchMatchColor, - ), - ); + const TextStyle(color: Colors.black, backgroundColor: searchMatchColor), + ); TextStyle get legendTextStyle => fixBlurryText( - const TextStyle( - fontWeight: FontWeight.normal, - fontSize: smallFontSize, - decoration: TextDecoration.none, - ), - ); + const TextStyle( + fontWeight: FontWeight.normal, + fontSize: smallFontSize, + decoration: TextDecoration.none, + ), + ); } /// Returns a [TextStyle] with [FontFeature.proportionalFigures] applied to @@ -541,10 +515,7 @@ /// Measures the screen size to determine whether it is strictly larger /// than [width], scaled to the current font factor. -bool isScreenWiderThan( - BuildContext context, - double? width, -) { +bool isScreenWiderThan(BuildContext context, double? width) { return width == null || MediaQuery.of(context).size.width > width; }
diff --git a/packages/devtools_app_shared/lib/src/utils/auto_dispose.dart b/packages/devtools_app_shared/lib/src/utils/auto_dispose.dart index a0eff8a..a151245 100644 --- a/packages/devtools_app_shared/lib/src/utils/auto_dispose.dart +++ b/packages/devtools_app_shared/lib/src/utils/auto_dispose.dart
@@ -191,8 +191,9 @@ if (listener == null) return; assert(_listenables.length == _listeners.length); - final foundIndex = - _listeners.indexWhere((currentListener) => currentListener == listener); + final foundIndex = _listeners.indexWhere( + (currentListener) => currentListener == listener, + ); if (foundIndex == -1) return; _listenables[foundIndex].removeListener(_listeners[foundIndex]); _listenables.removeAt(foundIndex); @@ -350,9 +351,7 @@ /// /// If any index in [indices] is out of range, an exception will be thrown. void removeAllExceptIndices(List<int> indices) { - final tmp = [ - for (final index in indices) this[index], - ]; + final tmp = [for (final index in indices) this[index]]; clear(); addAll(tmp); }
diff --git a/packages/devtools_app_shared/lib/src/utils/url/_url_web.dart b/packages/devtools_app_shared/lib/src/utils/url/_url_web.dart index 67e84ee..4e81763 100644 --- a/packages/devtools_app_shared/lib/src/utils/url/_url_web.dart +++ b/packages/devtools_app_shared/lib/src/utils/url/_url_web.dart
@@ -27,13 +27,10 @@ } else { newQueryParams[key] = value; } - final newUri = Uri.parse(window.location.toString()) - .replace(queryParameters: newQueryParams); - window.history.replaceState( - window.history.state, - '', - newUri.toString(), - ); + final newUri = Uri.parse( + window.location.toString(), + ).replace(queryParameters: newQueryParams); + window.history.replaceState(window.history.state, '', newUri.toString()); if (reload) { window.location.reload();
diff --git a/packages/devtools_app_shared/test/service/flutter_version_test.dart b/packages/devtools_app_shared/test/service/flutter_version_test.dart index a1904d6..8c8059f 100644 --- a/packages/devtools_app_shared/test/service/flutter_version_test.dart +++ b/packages/devtools_app_shared/test/service/flutter_version_test.dart
@@ -8,40 +8,45 @@ void main() { group('FlutterVersion', () { test('infers semantic version', () { - var flutterVersion = - FlutterVersion.parse({'frameworkVersion': '1.10.7-pre.42'}); + var flutterVersion = FlutterVersion.parse({ + 'frameworkVersion': '1.10.7-pre.42', + }); expect(flutterVersion.major, equals(1)); expect(flutterVersion.minor, equals(10)); expect(flutterVersion.patch, equals(7)); expect(flutterVersion.preReleaseMajor, equals(42)); expect(flutterVersion.preReleaseMinor, equals(0)); - flutterVersion = - FlutterVersion.parse({'frameworkVersion': '1.10.7-pre42'}); + flutterVersion = FlutterVersion.parse({ + 'frameworkVersion': '1.10.7-pre42', + }); expect(flutterVersion.major, equals(1)); expect(flutterVersion.minor, equals(10)); expect(flutterVersion.patch, equals(7)); expect(flutterVersion.preReleaseMajor, equals(42)); expect(flutterVersion.preReleaseMinor, equals(0)); - flutterVersion = - FlutterVersion.parse({'frameworkVersion': '1.10.11-pre42'}); + flutterVersion = FlutterVersion.parse({ + 'frameworkVersion': '1.10.11-pre42', + }); expect(flutterVersion.major, equals(1)); expect(flutterVersion.minor, equals(10)); expect(flutterVersion.patch, equals(11)); expect(flutterVersion.preReleaseMajor, equals(42)); expect(flutterVersion.preReleaseMinor, equals(0)); - flutterVersion = - FlutterVersion.parse({'frameworkVersion': '2.3.0-17.0.pre.355'}); + flutterVersion = FlutterVersion.parse({ + 'frameworkVersion': '2.3.0-17.0.pre.355', + }); expect(flutterVersion.major, equals(2)); expect(flutterVersion.minor, equals(3)); expect(flutterVersion.patch, equals(0)); expect(flutterVersion.preReleaseMajor, equals(17)); expect(flutterVersion.preReleaseMinor, equals(0)); - flutterVersion = - FlutterVersion.parse({'frameworkVersion': '2.3.0-17.0.pre'}); + flutterVersion = FlutterVersion.parse({ + 'frameworkVersion': '2.3.0-17.0.pre', + }); expect(flutterVersion.major, equals(2)); expect(flutterVersion.minor, equals(3)); expect(flutterVersion.patch, equals(0)); @@ -62,8 +67,9 @@ expect(flutterVersion.preReleaseMajor, isNull); expect(flutterVersion.preReleaseMinor, isNull); - flutterVersion = - FlutterVersion.parse({'frameworkVersion': 'bad-version'}); + flutterVersion = FlutterVersion.parse({ + 'frameworkVersion': 'bad-version', + }); expect(flutterVersion.major, equals(0)); expect(flutterVersion.minor, equals(0)); expect(flutterVersion.patch, equals(0)); @@ -72,33 +78,44 @@ group('identifies correct Flutter channel', () { test('uses channel string if it exists', () { expect( - FlutterVersion.identifyChannel('ignored-version', - channelStr: 'dev'), - equals(FlutterChannel.dev)); + FlutterVersion.identifyChannel('ignored-version', channelStr: 'dev'), + equals(FlutterChannel.dev), + ); expect( - FlutterVersion.identifyChannel('ignored-version', - channelStr: 'beta'), - equals(FlutterChannel.beta)); + FlutterVersion.identifyChannel('ignored-version', channelStr: 'beta'), + equals(FlutterChannel.beta), + ); expect( - FlutterVersion.identifyChannel('ignored-version', - channelStr: 'stable'), - equals(FlutterChannel.stable)); + FlutterVersion.identifyChannel( + 'ignored-version', + channelStr: 'stable', + ), + equals(FlutterChannel.stable), + ); }); test('identifies channel from version string', () { - expect(FlutterVersion.identifyChannel('2.3.0-17.0.pre.355'), - equals(FlutterChannel.dev)); + expect( + FlutterVersion.identifyChannel('2.3.0-17.0.pre.355'), + equals(FlutterChannel.dev), + ); - expect(FlutterVersion.identifyChannel('2.3.0-17.0.pre-355'), - equals(FlutterChannel.dev)); + expect( + FlutterVersion.identifyChannel('2.3.0-17.0.pre-355'), + equals(FlutterChannel.dev), + ); - expect(FlutterVersion.identifyChannel('2.3.0-17.0.pre'), - equals(FlutterChannel.beta)); + expect( + FlutterVersion.identifyChannel('2.3.0-17.0.pre'), + equals(FlutterChannel.beta), + ); - expect(FlutterVersion.identifyChannel('2.3.0'), - equals(FlutterChannel.stable)); + expect( + FlutterVersion.identifyChannel('2.3.0'), + equals(FlutterChannel.stable), + ); expect(FlutterVersion.identifyChannel('bad-version'), isNull);
diff --git a/packages/devtools_app_shared/test/test_utils.dart b/packages/devtools_app_shared/test/test_utils.dart index 8c04ae0..5a36b4e 100644 --- a/packages/devtools_app_shared/test/test_utils.dart +++ b/packages/devtools_app_shared/test/test_utils.dart
@@ -21,15 +21,9 @@ theme: themeFor( isDarkTheme: false, ideTheme: IdeTheme(), - theme: ThemeData( - useMaterial3: true, - colorScheme: lightColorScheme, - ), + theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme), ), - home: Directionality( - textDirection: TextDirection.ltr, - child: widget, - ), + home: Directionality(textDirection: TextDirection.ltr, child: widget), ); } @@ -40,15 +34,11 @@ WidgetTesterCallback test, { bool skip = false, }) { - testWidgets( - name, - (WidgetTester tester) async { - await _setWindowSize(tester, windowSize); - await test(tester); - await _resetWindowSize(tester); - }, - skip: skip, - ); + testWidgets(name, (WidgetTester tester) async { + await _setWindowSize(tester, windowSize); + await test(tester); + await _resetWindowSize(tester); + }, skip: skip); } Future<void> _setWindowSize(WidgetTester tester, Size windowSize) async {
diff --git a/packages/devtools_app_shared/test/ui/common_test.dart b/packages/devtools_app_shared/test/ui/common_test.dart index c0cecde..21f96b9 100644 --- a/packages/devtools_app_shared/test/ui/common_test.dart +++ b/packages/devtools_app_shared/test/ui/common_test.dart
@@ -17,52 +17,30 @@ group('AreaPaneHeader', () { const titleText = 'The title'; - testWidgets( - 'actions do not take up space when not present', - (WidgetTester tester) async { - await tester.pumpWidget( - wrap( - const AreaPaneHeader( - title: Text(titleText), - ), - ), - ); + testWidgets('actions do not take up space when not present', ( + WidgetTester tester, + ) async { + await tester.pumpWidget( + wrap(const AreaPaneHeader(title: Text(titleText))), + ); - final row = tester.widget(find.byType(Row)) as Row; - expect( - row.children.length, - equals(1), - ); - expect( - find.text(titleText), - findsOneWidget, - ); - }, - ); + final row = tester.widget(find.byType(Row)) as Row; + expect(row.children.length, equals(1)); + expect(find.text(titleText), findsOneWidget); + }); testWidgets('shows actions', (WidgetTester tester) async { const actionText = 'The Action Text'; const action = Text(actionText); await tester.pumpWidget( - wrap( - const AreaPaneHeader( - title: Text(titleText), - actions: [action], - ), - ), + wrap(const AreaPaneHeader(title: Text(titleText), actions: [action])), ); final row = tester.widget(find.byType(Row)) as Row; - expect( - row.children.length, - equals(2), - ); + expect(row.children.length, equals(2)); expect(find.text(actionText), findsOneWidget); - expect( - find.text(titleText), - findsOneWidget, - ); + expect(find.text(titleText), findsOneWidget); }); }); }
diff --git a/packages/devtools_app_shared/test/ui/flex_split_column_test.dart b/packages/devtools_app_shared/test/ui/flex_split_column_test.dart index abeecd2..44d48a1 100644 --- a/packages/devtools_app_shared/test/ui/flex_split_column_test.dart +++ b/packages/devtools_app_shared/test/ui/flex_split_column_test.dart
@@ -40,33 +40,31 @@ test('modifyInitialFractionsToIncludeFirstHeader', () { final adjustedFractions = FlexSplitColumn.modifyInitialFractionsToIncludeFirstHeader( - initialFractions, - headers, - totalHeight, - ); + initialFractions, + headers, + totalHeight, + ); expect( - const DeepCollectionEquality().equals( - adjustedFractions, - [ - 0.2857142857142857, - 0.23809523809523808, - 0.23809523809523808, - 0.23809523809523808, - ], - ), + const DeepCollectionEquality().equals(adjustedFractions, [ + 0.2857142857142857, + 0.23809523809523808, + 0.23809523809523808, + 0.23809523809523808, + ]), isTrue, ); }); test('modifyMinSizesToIncludeFirstHeader', () { final adjustedFractions = - FlexSplitColumn.modifyMinSizesToIncludeFirstHeader( - minSizes, - headers, - ); + FlexSplitColumn.modifyMinSizesToIncludeFirstHeader(minSizes, headers); expect( - const DeepCollectionEquality() - .equals(adjustedFractions, [60.0, 10.0, 10.0, 10.0]), + const DeepCollectionEquality().equals(adjustedFractions, [ + 60.0, + 10.0, + 10.0, + 10.0, + ]), isTrue, ); }); @@ -77,10 +75,10 @@ // Wrap each child in a container so we can build the elements in a // arbitrary column to check for [firstHeaderKey]. - final adjustedChildren = - FlexSplitColumn.buildChildrenWithFirstHeader(children, headers) - .map((child) => SizedBox(height: 100.0, child: child)) - .toList(); + final adjustedChildren = FlexSplitColumn.buildChildrenWithFirstHeader( + children, + headers, + ).map((child) => SizedBox(height: 100.0, child: child)).toList(); await tester.pumpWidget(Column(children: adjustedChildren)); expect(find.byKey(firstHeaderKey), findsOneWidget); });
diff --git a/packages/devtools_app_shared/test/ui/split_pane_test.dart b/packages/devtools_app_shared/test/ui/split_pane_test.dart index 068f9ed..2082752 100644 --- a/packages/devtools_app_shared/test/ui/split_pane_test.dart +++ b/packages/devtools_app_shared/test/ui/split_pane_test.dart
@@ -83,8 +83,10 @@ }); testWidgets('with 0% space to first child', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.horizontal, initialFractions: [0.0, 1.0]); + final split = buildSplitPane( + Axis.horizontal, + initialFractions: [0.0, 1.0], + ); await tester.pumpWidget(wrap(split)); expect(find.byKey(_k1), findsOneWidget); expect(find.byKey(_k2), findsOneWidget); @@ -103,31 +105,30 @@ ); }); - testWidgets( - 'with 100% space to first child', - (WidgetTester tester) async { - final split = buildSplitPane( - Axis.horizontal, - initialFractions: [1.0, 0.0], - ); - await tester.pumpWidget(wrap(split)); - expect(find.byKey(_k1), findsOneWidget); - expect(find.byKey(_k2), findsOneWidget); - expect(find.byKey(split.dividerKey(0)), findsOneWidget); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(788, 600), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(0, 600), - ); - expectEqualSizes( - tester.element(find.byKey(split.dividerKey(0))).size!, - const Size(12, 600), - ); - }, - ); + testWidgets('with 100% space to first child', ( + WidgetTester tester, + ) async { + final split = buildSplitPane( + Axis.horizontal, + initialFractions: [1.0, 0.0], + ); + await tester.pumpWidget(wrap(split)); + expect(find.byKey(_k1), findsOneWidget); + expect(find.byKey(_k2), findsOneWidget); + expect(find.byKey(split.dividerKey(0)), findsOneWidget); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(788, 600), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(0, 600), + ); + expectEqualSizes( + tester.element(find.byKey(split.dividerKey(0))).size!, + const Size(12, 600), + ); + }); testWidgets('with n children', (WidgetTester tester) async { final split = buildSplitPane( @@ -172,36 +173,37 @@ ); }); - testWidgets( - 'with initialFraction rounding errors', - (WidgetTester tester) async { - const oneThird = 0.333333; - final split = buildSplitPane( - Axis.horizontal, - children: [_w1, _w2, _w3], - initialFractions: [oneThird, oneThird, oneThird], - ); - await tester.pumpWidget(wrap(split)); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(258.666416, 600), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(258.666416, 600), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(258.666416, 600), - ); - }, - ); + testWidgets('with initialFraction rounding errors', ( + WidgetTester tester, + ) async { + const oneThird = 0.333333; + final split = buildSplitPane( + Axis.horizontal, + children: [_w1, _w2, _w3], + initialFractions: [oneThird, oneThird, oneThird], + ); + await tester.pumpWidget(wrap(split)); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(258.666416, 600), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(258.666416, 600), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(258.666416, 600), + ); + }); }); group('builds vertical layout', () { testWidgets('with 25% space to first child', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.vertical, initialFractions: [0.25, 0.75]); + final split = buildSplitPane( + Axis.vertical, + initialFractions: [0.25, 0.75], + ); await tester.pumpWidget(wrap(split)); expect(find.byKey(_k1), findsOneWidget); expect(find.byKey(_k2), findsOneWidget); @@ -221,8 +223,10 @@ }); testWidgets('with 50% space to first child', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.vertical, initialFractions: [0.5, 0.5]); + final split = buildSplitPane( + Axis.vertical, + initialFractions: [0.5, 0.5], + ); await tester.pumpWidget(wrap(split)); expectEqualSizes( tester.element(find.byKey(_k1)).size!, @@ -235,8 +239,10 @@ }); testWidgets('with 75% space to first child', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.vertical, initialFractions: [0.75, 0.25]); + final split = buildSplitPane( + Axis.vertical, + initialFractions: [0.75, 0.25], + ); await tester.pumpWidget(wrap(split)); expectEqualSizes( tester.element(find.byKey(_k1)).size!, @@ -249,8 +255,10 @@ }); testWidgets('with 0% space to first child', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.vertical, initialFractions: [0.0, 1.0]); + final split = buildSplitPane( + Axis.vertical, + initialFractions: [0.0, 1.0], + ); await tester.pumpWidget(wrap(split)); expect(find.byKey(_k1), findsOneWidget); expect(find.byKey(_k2), findsOneWidget); @@ -269,29 +277,30 @@ ); }); - testWidgets( - 'with 100% space to first child', - (WidgetTester tester) async { - final split = - buildSplitPane(Axis.vertical, initialFractions: [1.0, 0.0]); - await tester.pumpWidget(wrap(split)); - expect(find.byKey(_k1), findsOneWidget); - expect(find.byKey(_k2), findsOneWidget); - expect(find.byKey(split.dividerKey(0)), findsOneWidget); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(800, 588), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(800, 0), - ); - expectEqualSizes( - tester.element(find.byKey(split.dividerKey(0))).size!, - const Size(800, 12), - ); - }, - ); + testWidgets('with 100% space to first child', ( + WidgetTester tester, + ) async { + final split = buildSplitPane( + Axis.vertical, + initialFractions: [1.0, 0.0], + ); + await tester.pumpWidget(wrap(split)); + expect(find.byKey(_k1), findsOneWidget); + expect(find.byKey(_k2), findsOneWidget); + expect(find.byKey(split.dividerKey(0)), findsOneWidget); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(800, 588), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(800, 0), + ); + expectEqualSizes( + tester.element(find.byKey(split.dividerKey(0))).size!, + const Size(800, 12), + ); + }); testWidgets('with n children', (WidgetTester tester) async { final split = buildSplitPane( @@ -336,36 +345,37 @@ ); }); - testWidgets( - 'with initialFraction rounding errors', - (WidgetTester tester) async { - const oneThird = 0.333333; - final split = buildSplitPane( - Axis.vertical, - children: [_w1, _w2, _w3], - initialFractions: [oneThird, oneThird, oneThird], - ); - await tester.pumpWidget(wrap(split)); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(800, 191.99981599999998), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(800, 191.99981599999998), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(800, 191.99981599999998), - ); - }, - ); + testWidgets('with initialFraction rounding errors', ( + WidgetTester tester, + ) async { + const oneThird = 0.333333; + final split = buildSplitPane( + Axis.vertical, + children: [_w1, _w2, _w3], + initialFractions: [oneThird, oneThird, oneThird], + ); + await tester.pumpWidget(wrap(split)); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(800, 191.99981599999998), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(800, 191.99981599999998), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(800, 191.99981599999998), + ); + }); }); group('drags properly', () { testWidgets('with horizontal layout', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.horizontal, initialFractions: [0.5, 0.5]); + final split = buildSplitPane( + Axis.horizontal, + initialFractions: [0.5, 0.5], + ); await tester.pumpWidget(wrap(split)); // We start at 0.5 size. @@ -470,8 +480,10 @@ }); testWidgets('with vertical layout', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.vertical, initialFractions: [0.5, 0.5]); + final split = buildSplitPane( + Axis.vertical, + initialFractions: [0.5, 0.5], + ); await tester.pumpWidget(wrap(split)); // We start at 0.5 size. @@ -811,13 +823,13 @@ group('resizes contents', () { testWidgets('in a horizontal layout', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.horizontal, initialFractions: [0.0, 1.0]); + final split = buildSplitPane( + Axis.horizontal, + initialFractions: [0.0, 1.0], + ); await tester.pumpWidget( wrap( - Center( - child: SizedBox(width: 300.0, height: 300.0, child: split), - ), + Center(child: SizedBox(width: 300.0, height: 300.0, child: split)), ), ); expectEqualSizes( @@ -831,9 +843,7 @@ await tester.pumpWidget( wrap( - Center( - child: SizedBox(width: 200.0, height: 200.0, child: split), - ), + Center(child: SizedBox(width: 200.0, height: 200.0, child: split)), ), ); expectEqualSizes( @@ -846,235 +856,214 @@ ); }); - testWidgets( - 'in a horizontal layout with n children', - (WidgetTester tester) async { - final split = buildSplitPane( - Axis.horizontal, - children: [_w1, _w2, _w3], - initialFractions: [0.2, 0.4, 0.4], - ); - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 400.0, height: 400.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(75.2, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(150.4, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(150.4, 400), - ); - - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 200.0, height: 200.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(35.2, 200), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(70.4, 200), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(70.4, 200), - ); - }, - ); - - testWidgets( - 'with violated minsize constraints', - (WidgetTester tester) async { - final split = buildSplitPane( - Axis.horizontal, - children: [_w1, _w2, _w3], - initialFractions: [0.1, 0.7, 0.2], - minSizes: [100.0, 0, 100.0], - ); - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 400.0, height: 400.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(100, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(176.0, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(100, 400), - ); - - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 230.0, height: 200.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(100.0, 200), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(6.0, 200), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(100.0, 200), - ); - - // It would be nice if we restored the size of w2 in this case but the - // logic is simpler if we don't as this way the layout calculation can - // avoid tracking state about what the previous fractions were before - // clipping which would add more complexity and shouldn't really matter. - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 400.0, height: 400.0, child: split), - ), - ), - ); - // TODO(dantup): These now fail, as the results are 100/176/100. It's not - // clear why these expectations are different to the above when it's - // in the same size box? - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(182.5242718446602, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(10.951456310679607, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(182.5242718446602, 400), - ); - }, - ); - - testWidgets( - 'with impossible minsize constraints', - (WidgetTester tester) async { - final split = buildSplitPane( - Axis.horizontal, - children: [_w1, _w2, _w3], - initialFractions: [0.2, 0.4, 0.4], - minSizes: [200.0, 0, 400.0], - ); - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 400.0, height: 400.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(125.33333333333333, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(0, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(250.66666666666666, 400), - ); - - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 200.0, height: 200.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(58.666666666666664, 200), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(0, 200), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(117.33333333333333, 200), - ); - - // Min size constraints still violated but not violated by as much. - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 400.0, height: 400.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(125.33333333333333, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(0, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(250.66666666666666, 400), - ); - - // Min size constraints are now satisfied. - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 800.0, height: 400.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(258.66666666666666, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(0, 400), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(517.3333333333333, 400), - ); - }, - ); - - testWidgets('in a vertical layout', (WidgetTester tester) async { - final split = - buildSplitPane(Axis.vertical, initialFractions: [0.0, 1.0]); + testWidgets('in a horizontal layout with n children', ( + WidgetTester tester, + ) async { + final split = buildSplitPane( + Axis.horizontal, + children: [_w1, _w2, _w3], + initialFractions: [0.2, 0.4, 0.4], + ); await tester.pumpWidget( wrap( - Center( - child: SizedBox(width: 300.0, height: 300.0, child: split), - ), + Center(child: SizedBox(width: 400.0, height: 400.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(75.2, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(150.4, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(150.4, 400), + ); + + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 200.0, height: 200.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(35.2, 200), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(70.4, 200), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(70.4, 200), + ); + }); + + testWidgets('with violated minsize constraints', ( + WidgetTester tester, + ) async { + final split = buildSplitPane( + Axis.horizontal, + children: [_w1, _w2, _w3], + initialFractions: [0.1, 0.7, 0.2], + minSizes: [100.0, 0, 100.0], + ); + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 400.0, height: 400.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(100, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(176.0, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(100, 400), + ); + + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 230.0, height: 200.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(100.0, 200), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(6.0, 200), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(100.0, 200), + ); + + // It would be nice if we restored the size of w2 in this case but the + // logic is simpler if we don't as this way the layout calculation can + // avoid tracking state about what the previous fractions were before + // clipping which would add more complexity and shouldn't really matter. + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 400.0, height: 400.0, child: split)), + ), + ); + // TODO(dantup): These now fail, as the results are 100/176/100. It's not + // clear why these expectations are different to the above when it's + // in the same size box? + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(182.5242718446602, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(10.951456310679607, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(182.5242718446602, 400), + ); + }); + + testWidgets('with impossible minsize constraints', ( + WidgetTester tester, + ) async { + final split = buildSplitPane( + Axis.horizontal, + children: [_w1, _w2, _w3], + initialFractions: [0.2, 0.4, 0.4], + minSizes: [200.0, 0, 400.0], + ); + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 400.0, height: 400.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(125.33333333333333, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(0, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(250.66666666666666, 400), + ); + + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 200.0, height: 200.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(58.666666666666664, 200), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(0, 200), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(117.33333333333333, 200), + ); + + // Min size constraints still violated but not violated by as much. + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 400.0, height: 400.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(125.33333333333333, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(0, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(250.66666666666666, 400), + ); + + // Min size constraints are now satisfied. + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 800.0, height: 400.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(258.66666666666666, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(0, 400), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(517.3333333333333, 400), + ); + }); + + testWidgets('in a vertical layout', (WidgetTester tester) async { + final split = buildSplitPane( + Axis.vertical, + initialFractions: [0.0, 1.0], + ); + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 300.0, height: 300.0, child: split)), ), ); expectEqualSizes( @@ -1088,9 +1077,7 @@ await tester.pumpWidget( wrap( - Center( - child: SizedBox(width: 200.0, height: 200.0, child: split), - ), + Center(child: SizedBox(width: 200.0, height: 200.0, child: split)), ), ); expectEqualSizes( @@ -1103,116 +1090,109 @@ ); }); - testWidgets( - 'in a vertical layout with n children', - (WidgetTester tester) async { - final split = buildSplitPane( - Axis.vertical, - children: [_w1, _w2, _w3], - initialFractions: [0.2, 0.4, 0.4], - ); - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 400.0, height: 400.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(400, 75.2), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(400, 150.4), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(400, 150.4), - ); + testWidgets('in a vertical layout with n children', ( + WidgetTester tester, + ) async { + final split = buildSplitPane( + Axis.vertical, + children: [_w1, _w2, _w3], + initialFractions: [0.2, 0.4, 0.4], + ); + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 400.0, height: 400.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(400, 75.2), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(400, 150.4), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(400, 150.4), + ); - await tester.pumpWidget( - wrap( - Center( - child: SizedBox(width: 200.0, height: 200.0, child: split), - ), - ), - ); - expectEqualSizes( - tester.element(find.byKey(_k1)).size!, - const Size(200, 35.2), - ); - expectEqualSizes( - tester.element(find.byKey(_k2)).size!, - const Size(200, 70.4), - ); - expectEqualSizes( - tester.element(find.byKey(_k3)).size!, - const Size(200, 70.4), - ); - }, - ); + await tester.pumpWidget( + wrap( + Center(child: SizedBox(width: 200.0, height: 200.0, child: split)), + ), + ); + expectEqualSizes( + tester.element(find.byKey(_k1)).size!, + const Size(200, 35.2), + ); + expectEqualSizes( + tester.element(find.byKey(_k2)).size!, + const Size(200, 70.4), + ); + expectEqualSizes( + tester.element(find.byKey(_k3)).size!, + const Size(200, 70.4), + ); + }); }); group('rebuilds with a different number of children', () { - testWidgets( - 'does not throw a RangeError when child count shrinks', - (WidgetTester tester) async { - final threeChildSplit = buildSplitPane( - Axis.horizontal, - children: const [_w1, _w2, _w3], - initialFractions: const [0.2, 0.4, 0.4], - minSizes: const [50.0, 50.0, 50.0], - ); - await tester.pumpWidget(wrap(threeChildSplit)); - expect(find.byKey(_k1), findsOneWidget); - expect(find.byKey(_k2), findsOneWidget); - expect(find.byKey(_k3), findsOneWidget); + testWidgets('does not throw a RangeError when child count shrinks', ( + WidgetTester tester, + ) async { + final threeChildSplit = buildSplitPane( + Axis.horizontal, + children: const [_w1, _w2, _w3], + initialFractions: const [0.2, 0.4, 0.4], + minSizes: const [50.0, 50.0, 50.0], + ); + await tester.pumpWidget(wrap(threeChildSplit)); + expect(find.byKey(_k1), findsOneWidget); + expect(find.byKey(_k2), findsOneWidget); + expect(find.byKey(_k3), findsOneWidget); - final twoChildSplit = buildSplitPane( - Axis.horizontal, - children: const [_w1, _w2], - initialFractions: const [0.5, 0.5], - minSizes: const [50.0, 50.0], - ); - await tester.pumpWidget(wrap(twoChildSplit)); - await tester.pumpAndSettle(); + final twoChildSplit = buildSplitPane( + Axis.horizontal, + children: const [_w1, _w2], + initialFractions: const [0.5, 0.5], + minSizes: const [50.0, 50.0], + ); + await tester.pumpWidget(wrap(twoChildSplit)); + await tester.pumpAndSettle(); - expect(tester.takeException(), isNull); - expect(find.byKey(_k1), findsOneWidget); - expect(find.byKey(_k2), findsOneWidget); - expect(find.byKey(_k3), findsNothing); - }, - ); + expect(tester.takeException(), isNull); + expect(find.byKey(_k1), findsOneWidget); + expect(find.byKey(_k2), findsOneWidget); + expect(find.byKey(_k3), findsNothing); + }); - testWidgets( - 'does not throw a RangeError when child count grows', - (WidgetTester tester) async { - final twoChildSplit = buildSplitPane( - Axis.horizontal, - children: const [_w1, _w2], - initialFractions: const [0.5, 0.5], - minSizes: const [50.0, 50.0], - ); - await tester.pumpWidget(wrap(twoChildSplit)); - expect(find.byKey(_k1), findsOneWidget); - expect(find.byKey(_k2), findsOneWidget); + testWidgets('does not throw a RangeError when child count grows', ( + WidgetTester tester, + ) async { + final twoChildSplit = buildSplitPane( + Axis.horizontal, + children: const [_w1, _w2], + initialFractions: const [0.5, 0.5], + minSizes: const [50.0, 50.0], + ); + await tester.pumpWidget(wrap(twoChildSplit)); + expect(find.byKey(_k1), findsOneWidget); + expect(find.byKey(_k2), findsOneWidget); - final threeChildSplit = buildSplitPane( - Axis.horizontal, - children: const [_w1, _w2, _w3], - initialFractions: const [0.2, 0.4, 0.4], - minSizes: const [50.0, 50.0, 50.0], - ); - await tester.pumpWidget(wrap(threeChildSplit)); - await tester.pumpAndSettle(); + final threeChildSplit = buildSplitPane( + Axis.horizontal, + children: const [_w1, _w2, _w3], + initialFractions: const [0.2, 0.4, 0.4], + minSizes: const [50.0, 50.0, 50.0], + ); + await tester.pumpWidget(wrap(threeChildSplit)); + await tester.pumpAndSettle(); - expect(tester.takeException(), isNull); - expect(find.byKey(_k1), findsOneWidget); - expect(find.byKey(_k2), findsOneWidget); - expect(find.byKey(_k3), findsOneWidget); - }, - ); + expect(tester.takeException(), isNull); + expect(find.byKey(_k1), findsOneWidget); + expect(find.byKey(_k2), findsOneWidget); + expect(find.byKey(_k3), findsOneWidget); + }); }); group('axisFor', () { @@ -1224,8 +1204,12 @@ wrap( Builder( builder: (context) { - unawaited(expectLater( - SplitPane.axisFor(context, 1.0), Axis.horizontal)); + unawaited( + expectLater( + SplitPane.axisFor(context, 1.0), + Axis.horizontal, + ), + ); return Container(); }, ), @@ -1233,23 +1217,22 @@ ); }, ); - testWidgetsWithWindowSize( - 'return Axis.vertical', - const Size(500, 800), - (WidgetTester tester) async { - await tester.pumpWidget( - wrap( - Builder( - builder: (context) { - unawaited(expectLater( - SplitPane.axisFor(context, 1.0), Axis.vertical)); - return Container(); - }, - ), + testWidgetsWithWindowSize('return Axis.vertical', const Size(500, 800), ( + WidgetTester tester, + ) async { + await tester.pumpWidget( + wrap( + Builder( + builder: (context) { + unawaited( + expectLater(SplitPane.axisFor(context, 1.0), Axis.vertical), + ); + return Container(); + }, ), - ); - }, - ); + ), + ); + }); }); }); }
diff --git a/packages/devtools_app_shared/test/ui/theme_test.dart b/packages/devtools_app_shared/test/ui/theme_test.dart index 29043fe..c5ffa4d 100644 --- a/packages/devtools_app_shared/test/ui/theme_test.dart +++ b/packages/devtools_app_shared/test/ui/theme_test.dart
@@ -19,40 +19,25 @@ theme = themeFor( isDarkTheme: true, ideTheme: IdeTheme(), - theme: ThemeData( - useMaterial3: true, - colorScheme: darkColorScheme, - ), + theme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme), ); expect(theme.brightness, equals(Brightness.dark)); - expect( - theme.scaffoldBackgroundColor, - equals(darkColorScheme.surface), - ); + expect(theme.scaffoldBackgroundColor, equals(darkColorScheme.surface)); theme = themeFor( isDarkTheme: false, ideTheme: IdeTheme(), - theme: ThemeData( - useMaterial3: true, - colorScheme: lightColorScheme, - ), + theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme), ); expect(theme.brightness, equals(Brightness.light)); - expect( - theme.scaffoldBackgroundColor, - equals(lightColorScheme.surface), - ); + expect(theme.scaffoldBackgroundColor, equals(lightColorScheme.surface)); }); test('can be inferred from override background color', () { theme = themeFor( isDarkTheme: false, // Will be overridden by white BG ideTheme: IdeTheme(backgroundColor: Colors.white70), - theme: ThemeData( - useMaterial3: true, - colorScheme: lightColorScheme, - ), + theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme), ); expect(theme.brightness, equals(Brightness.light)); expect(theme.scaffoldBackgroundColor, equals(Colors.white70)); @@ -60,10 +45,7 @@ theme = themeFor( isDarkTheme: true, // Will be overridden by black BG ideTheme: IdeTheme(backgroundColor: Colors.black), - theme: ThemeData( - useMaterial3: true, - colorScheme: darkColorScheme, - ), + theme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme), ); expect(theme.brightness, equals(Brightness.dark)); expect(theme.scaffoldBackgroundColor, equals(Colors.black)); @@ -73,30 +55,18 @@ theme = themeFor( isDarkTheme: false, // Will not be overridden - not dark enough ideTheme: IdeTheme(backgroundColor: Colors.orange), - theme: ThemeData( - useMaterial3: true, - colorScheme: lightColorScheme, - ), + theme: ThemeData(useMaterial3: true, colorScheme: lightColorScheme), ); expect(theme.brightness, equals(Brightness.light)); - expect( - theme.scaffoldBackgroundColor, - equals(lightColorScheme.surface), - ); + expect(theme.scaffoldBackgroundColor, equals(lightColorScheme.surface)); theme = themeFor( isDarkTheme: true, // Will not be overridden - not light enough ideTheme: IdeTheme(backgroundColor: Colors.orange), - theme: ThemeData( - useMaterial3: true, - colorScheme: darkColorScheme, - ), + theme: ThemeData(useMaterial3: true, colorScheme: darkColorScheme), ); expect(theme.brightness, equals(Brightness.dark)); - expect( - theme.scaffoldBackgroundColor, - equals(darkColorScheme.surface), - ); + expect(theme.scaffoldBackgroundColor, equals(darkColorScheme.surface)); }); });
diff --git a/packages/devtools_app_shared/test/utils/utils_test.dart b/packages/devtools_app_shared/test/utils/utils_test.dart index 2568984..f342052 100644 --- a/packages/devtools_app_shared/test/utils/utils_test.dart +++ b/packages/devtools_app_shared/test/utils/utils_test.dart
@@ -46,17 +46,11 @@ test('parses 8 digit hex colors', () { expect(parseCssHexColor('#000000ff'), equals(Colors.black)); expect(parseCssHexColor('000000ff'), equals(Colors.black)); - expect( - parseCssHexColor('#00000000'), - equals(Colors.black.withAlpha(0)), - ); + expect(parseCssHexColor('#00000000'), equals(Colors.black.withAlpha(0))); expect(parseCssHexColor('00000000'), equals(Colors.black.withAlpha(0))); expect(parseCssHexColor('#ffffffff'), equals(Colors.white)); expect(parseCssHexColor('ffffffff'), equals(Colors.white)); - expect( - parseCssHexColor('#ffffff00'), - equals(Colors.white.withAlpha(0)), - ); + expect(parseCssHexColor('#ffffff00'), equals(Colors.white.withAlpha(0))); expect(parseCssHexColor('ffffff00'), equals(Colors.white.withAlpha(0))); expect( parseCssHexColor('#ff0000bb'),
diff --git a/packages/devtools_extensions/bin/_build_and_copy.dart b/packages/devtools_extensions/bin/_build_and_copy.dart index a3d2ee6..5fa0a58 100644 --- a/packages/devtools_extensions/bin/_build_and_copy.dart +++ b/packages/devtools_extensions/bin/_build_and_copy.dart
@@ -21,14 +21,16 @@ argParser ..addOption( _sourceKey, - help: 'The source location for the extension flutter web app (can be ' + help: + 'The source location for the extension flutter web app (can be ' 'relative or absolute)', valueHelp: 'path/to/foo/packages/foo_devtools_extension', mandatory: true, ) ..addOption( _destinationKey, - help: 'The destination location for the extension build output (can be ' + help: + 'The destination location for the extension build output (can be ' 'relative or absolute)', valueHelp: 'path/to/foo/packages/foo/extension/devtools', mandatory: true, @@ -71,17 +73,12 @@ // `chmod` or if we even need to perform `chmod` for linux / mac anymore. if (!Platform.isWindows) { _log('Setting canvaskit permissions...'); - await _runProcess( - processManager, - 'chmod', - [ - '0755', - // Note: using a wildcard `canvaskit.*` throws. - 'build/web/canvaskit/canvaskit.js', - 'build/web/canvaskit/canvaskit.wasm', - ], - workingDirectory: source, - ); + await _runProcess(processManager, 'chmod', [ + '0755', + // Note: using a wildcard `canvaskit.*` throws. + 'build/web/canvaskit/canvaskit.js', + 'build/web/canvaskit/canvaskit.wasm', + ], workingDirectory: source); } _log('Copying built output to the extension destination...'); @@ -102,10 +99,7 @@ } Directory(destinationBuildPath).createSync(recursive: true); - await copyPath( - sourceBuildPath, - destinationBuildPath, - ); + await copyPath(sourceBuildPath, destinationBuildPath); _log( 'Successfully copied extension assets from '
diff --git a/packages/devtools_extensions/bin/_validate.dart b/packages/devtools_extensions/bin/_validate.dart index 89cda33..a0542f3 100644 --- a/packages/devtools_extensions/bin/_validate.dart +++ b/packages/devtools_extensions/bin/_validate.dart
@@ -49,17 +49,15 @@ // Try to parse the config.yaml file. This will throw an exception if there // are parsing errors. - DevToolsExtensionConfig.parse( - { - ..._configAsMap(packagePath), - // These are generated on the DevTools server, so pass in stubbed - // values for the sake of validation. - DevToolsExtensionConfig.extensionAssetsPathKey: '', - DevToolsExtensionConfig.devtoolsOptionsUriKey: '', - DevToolsExtensionConfig.isPubliclyHostedKey: 'false', - DevToolsExtensionConfig.detectedFromStaticContextKey: 'false', - }, - ); + DevToolsExtensionConfig.parse({ + ..._configAsMap(packagePath), + // These are generated on the DevTools server, so pass in stubbed + // values for the sake of validation. + DevToolsExtensionConfig.extensionAssetsPathKey: '', + DevToolsExtensionConfig.devtoolsOptionsUriKey: '', + DevToolsExtensionConfig.isPubliclyHostedKey: 'false', + DevToolsExtensionConfig.detectedFromStaticContextKey: 'false', + }); // If there are no exceptions at this point, the extension has successfully // been validated. @@ -84,40 +82,32 @@ path.join(packageDirectory.path, 'extension', 'devtools'), ); if (!devtoolsExtensionDir.existsSync()) { - throw const FileSystemException( - ''' + throw const FileSystemException(''' An extension/devtools directory is required, but none was found. See ${ValidateExtensionCommand.docUrl}. -''', - ); +'''); } final buildDir = Directory(path.join(devtoolsExtensionDir.path, 'build')); if (!buildDir.existsSync()) { - throw const FileSystemException( - ''' + throw const FileSystemException(''' An extension/devtools/build directory is required, but none was found. See ${ValidateExtensionCommand.docUrl}. -''', - ); +'''); } if (buildDir.listSync().isEmpty) { - throw const FileSystemException( - ''' + throw const FileSystemException(''' A non-empty extension/devtools/build directory is required, but the directory is empty. See ${ValidateExtensionCommand.docUrl}. -''', - ); +'''); } final configFile = _lookupConfigFile(packagePath); if (!configFile.existsSync()) { - throw const FileSystemException( - ''' + throw const FileSystemException(''' An extension/devtools/config.yaml file is required, but none was found. See ${ValidateExtensionCommand.docUrl}. -''', - ); +'''); } } @@ -130,9 +120,7 @@ } File _lookupConfigFile(String packagePath) { - return File( - path.join(packagePath, 'extension', 'devtools', 'config.yaml'), - ); + return File(path.join(packagePath, 'extension', 'devtools', 'config.yaml')); } void _logError(String error) {
diff --git a/packages/devtools_extensions/integration_test/test/simulated_environment_test.dart b/packages/devtools_extensions/integration_test/test/simulated_environment_test.dart index 8816ee2..4e155ca 100644 --- a/packages/devtools_extensions/integration_test/test/simulated_environment_test.dart +++ b/packages/devtools_extensions/integration_test/test/simulated_environment_test.dart
@@ -21,9 +21,7 @@ IntegrationTestWidgetsFlutterBinding.ensureInitialized(); testWidgets('end to end simulated environment', (tester) async { - runApp( - const DevToolsExtension(child: TestDevToolsExtension()), - ); + runApp(const DevToolsExtension(child: TestDevToolsExtension())); await tester.pump(safePumpDuration); expect(find.byType(DevToolsExtension), findsOneWidget); expect(find.byType(TestDevToolsExtension), findsOneWidget); @@ -86,24 +84,22 @@ // Register a handler and verify it was called. int eventHandlerCalledCount = 0; - extensionManager.registerEventHandler( - DevToolsExtensionEventType.ping, - (event) { - eventHandlerCalledCount++; - }, - ); + extensionManager.registerEventHandler(DevToolsExtensionEventType.ping, ( + event, + ) { + eventHandlerCalledCount++; + }); await tester.tap(pingButtonFinder); await tester.pumpAndSettle(); expect(eventHandlerCalledCount, 1); // Register a different handler and verify it has replaced the original. int secondEventHandlerCalledCount = 0; - extensionManager.registerEventHandler( - DevToolsExtensionEventType.ping, - (event) { - secondEventHandlerCalledCount++; - }, - ); + extensionManager.registerEventHandler(DevToolsExtensionEventType.ping, ( + event, + ) { + secondEventHandlerCalledCount++; + }); await tester.tap(pingButtonFinder); await tester.pumpAndSettle(); @@ -205,8 +201,9 @@ matching: find.byType(SizedBox), ); - final environmentPanelSizedBoxWidth = - tester.firstWidget<SizedBox>(environmentPanelSizedBox).width!; + final environmentPanelSizedBoxWidth = tester + .firstWidget<SizedBox>(environmentPanelSizedBox) + .width!; // Check that the [environmentPanelSizedBoxWidth] is the expected width. expect( @@ -215,17 +212,12 @@ ); // Drag the divider to the right by [environmentPanelSizedBoxWidth]. - await tester.drag( - divider, - Offset( - environmentPanelSizedBoxWidth, - 0, - ), - ); + await tester.drag(divider, Offset(environmentPanelSizedBoxWidth, 0)); await tester.pumpAndSettle(); - final simulatedDevToolsWrapperRect = - tester.getRect(find.byType(SimulatedDevToolsWrapper)); + final simulatedDevToolsWrapperRect = tester.getRect( + find.byType(SimulatedDevToolsWrapper), + ); final environmentPanelRect = tester.getRect(find.byWidget(environmentPanel)); // Verify that the environment panel is off screen to the right of the @@ -238,13 +230,7 @@ // Drag the divider to the left by [environmentPanelSizedBoxWidth]. // // This is to bring the 'Clear logs' button into view so it can be tapped. - await tester.drag( - divider, - Offset( - -environmentPanelSizedBoxWidth, - 0, - ), - ); + await tester.drag(divider, Offset(-environmentPanelSizedBoxWidth, 0)); await tester.pumpAndSettle(); await _clearLogs(tester, simController); } @@ -276,9 +262,7 @@ ), body: const Column( mainAxisSize: MainAxisSize.min, - children: [ - CallingDevToolsExtensionsAPIsExample(), - ], + children: [CallingDevToolsExtensionsAPIsExample()], ), ); }
diff --git a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_controller.dart b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_controller.dart index 024550e..e1f2099 100644 --- a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_controller.dart +++ b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_controller.dart
@@ -93,10 +93,7 @@ void Function()? onUnknownEvent, }) { messageLogs.add( - MessageLogEntry( - source: MessageSource.extension, - data: event.toJson(), - ), + MessageLogEntry(source: MessageSource.extension, data: event.toJson()), ); } @@ -110,10 +107,7 @@ window.origin.toJS, ); messageLogs.add( - MessageLogEntry( - source: MessageSource.devtools, - data: eventJson, - ), + MessageLogEntry(source: MessageSource.devtools, data: eventJson), ); } @@ -153,7 +147,7 @@ @visibleForTesting class MessageLogEntry { MessageLogEntry({required this.source, this.data, this.message}) - : timestamp = DateTime.now(); + : timestamp = DateTime.now(); final MessageSource source; final Map<String, Object?>? data;
diff --git a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_environment.dart b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_environment.dart index 1305aab..f674c25 100644 --- a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_environment.dart +++ b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/_simulated_devtools_environment.dart
@@ -193,10 +193,7 @@ children: [ Row( children: [ - DevToolsButton( - label: 'PING', - onPressed: simController.ping, - ), + DevToolsButton(label: 'PING', onPressed: simController.ping), const SizedBox(width: denseSpacing), DevToolsButton( label: 'TOGGLE THEME', @@ -245,10 +242,7 @@ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - 'Logs:', - style: Theme.of(context).textTheme.titleMedium, - ), + Text('Logs:', style: Theme.of(context).textTheme.titleMedium), DevToolsButton.iconOnly( icon: Icons.clear, outlined: false, @@ -258,11 +252,7 @@ ], ), const PaddedDivider.thin(), - Expanded( - child: _LogMessages( - simController: simController, - ), - ), + Expanded(child: _LogMessages(simController: simController)), ], ); } @@ -333,10 +323,7 @@ style: Theme.of(context).fixedFontStyle, ), if (log.message != null) Text(log.message!), - if (log.data != null) - FormattedJson( - json: log.data, - ), + if (log.data != null) FormattedJson(json: log.data), ], ), );
diff --git a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_connect.dart b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_connect.dart index 2439d9d..8d5028b 100644 --- a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_connect.dart +++ b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_connect.dart
@@ -77,19 +77,11 @@ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - label, - style: theme.regularTextStyle, - ), - Text( - currentConnection(), - style: theme.boldTextStyle, - ), + Text(label, style: theme.regularTextStyle), + Text(currentConnection(), style: theme.boldTextStyle), ], ), - const Expanded( - child: SizedBox(width: denseSpacing), - ), + const Expanded(child: SizedBox(width: denseSpacing)), DevToolsButton( elevated: true, label: 'Disconnect', @@ -97,10 +89,7 @@ ), if (help != null) ...[ const SizedBox(width: denseSpacing), - _ConnectionHelpButton( - dialogTitle: '$label help', - child: help!, - ), + _ConnectionHelpButton(dialogTitle: '$label help', child: help!), ], ], ); @@ -189,10 +178,7 @@ } class _ConnectionHelpButton extends StatelessWidget { - const _ConnectionHelpButton({ - required this.dialogTitle, - required this.child, - }); + const _ConnectionHelpButton({required this.dialogTitle, required this.child}); final String dialogTitle; @@ -209,10 +195,7 @@ showDevToolsDialog( context: context, title: dialogTitle, - content: SizedBox( - width: helpContentWidth, - child: child, - ), + content: SizedBox(width: helpContentWidth, child: child), ); }, );
diff --git a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_dtd_connect.dart b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_dtd_connect.dart index fc2e64b..439deb9 100644 --- a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_dtd_connect.dart +++ b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_dtd_connect.dart
@@ -75,24 +75,20 @@ 'If your DevTools extension interacts with the Dart Tooling ' 'Daemon (DTD) through ', children: [ - TextSpan( - text: 'dtdManager', - style: theme.boldTextStyle, - ), + TextSpan(text: 'dtdManager', style: theme.boldTextStyle), const TextSpan( - text: ', then you will need to connect to a local instance ' + text: + ', then you will need to connect to a local instance ' 'of DTD to debug these features in the simulated ' 'environment. There are multiple ways to access a local ' 'instance of DTD:\n\n' '1. If you are running a Dart or Flutter application ' 'from command line, add the ', ), - TextSpan( - text: printDtdFlag, - style: theme.boldTextStyle, - ), + TextSpan(text: printDtdFlag, style: theme.boldTextStyle), const TextSpan( - text: ' flag. This will output a Dart Tooling Daemon URI to ' + text: + ' flag. This will output a Dart Tooling Daemon URI to ' 'the command line that you can copy.', ), ], @@ -119,7 +115,8 @@ RichText( text: TextSpan( style: theme.regularTextStyle, - text: '2. If you have a Dart or Flutter project open in your IDE ' + text: + '2. If you have a Dart or Flutter project open in your IDE ' '(VS Code, IntelliJ, or Android Studio), the IDE will have ' 'a running instance of DTD that you can use. Use the ' 'IDE\'s affordance to find an action (Command Pallette ' @@ -131,7 +128,8 @@ style: theme.boldTextStyle, ), const TextSpan( - text: ' action.\n\n' + text: + ' action.\n\n' 'Now, you should have a DTD URI in your clipboard. Paste ' 'this into the "Dart Tooling Daemon Connection" text ' 'field to connect.',
diff --git a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_vm_service_connect.dart b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_vm_service_connect.dart index e1fc42a..441149f 100644 --- a/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_vm_service_connect.dart +++ b/packages/devtools_extensions/lib/src/template/_simulated_devtools_environment/connection_ui/_vm_service_connect.dart
@@ -55,14 +55,12 @@ RichText( text: TextSpan( style: theme.regularTextStyle, - text: '1. Run a Dart or Flutter application. If you also need to ' + text: + '1. Run a Dart or Flutter application. If you also need to ' 'connect your extension to the Dart Tooling Daemon, run your ' 'app with the ', children: [ - TextSpan( - text: '--print-dtd', - style: theme.boldTextStyle, - ), + TextSpan(text: '--print-dtd', style: theme.boldTextStyle), const TextSpan(text: ' flag.'), ], ), @@ -74,12 +72,14 @@ text: '2. This will output text to the command line:', children: [ TextSpan( - text: ' "A Dart VM Service is available at: ' + text: + ' "A Dart VM Service is available at: ' 'http://127.0.0.1:53985/6RVz1q0e9ok=". ', style: theme.boldTextStyle, ), const TextSpan( - text: 'Copy the VM Service URI and paste it into the "Dart ' + text: + 'Copy the VM Service URI and paste it into the "Dart ' 'VM Service Connection" text field to connect.', ), ],
diff --git a/packages/devtools_extensions/lib/src/template/devtools_extension.dart b/packages/devtools_extensions/lib/src/template/devtools_extension.dart index 61c922c..5c9e43b 100644 --- a/packages/devtools_extensions/lib/src/template/devtools_extension.dart +++ b/packages/devtools_extensions/lib/src/template/devtools_extension.dart
@@ -37,8 +37,9 @@ /// "args": [ /// "--dart-define=use_simulated_environment=true" /// ] -const _simulatedEnvironmentEnabled = - bool.fromEnvironment('use_simulated_environment'); +const _simulatedEnvironmentEnabled = bool.fromEnvironment( + 'use_simulated_environment', +); bool get _useSimulatedEnvironment => !kReleaseMode && _simulatedEnvironmentEnabled;
diff --git a/packages/devtools_extensions/lib/src/template/extension_manager.dart b/packages/devtools_extensions/lib/src/template/extension_manager.dart index 07012e4..48bcaeb 100644 --- a/packages/devtools_extensions/lib/src/template/extension_manager.dart +++ b/packages/devtools_extensions/lib/src/template/extension_manager.dart
@@ -66,9 +66,7 @@ // respond with a [DevToolsPluginEventType.connectedVmService] event // containing the currently connected app's vm service URI. postMessageToDevTools( - DevToolsExtensionEvent( - DevToolsExtensionEventType.vmServiceConnection, - ), + DevToolsExtensionEvent(DevToolsExtensionEventType.vmServiceConnection), ); } else { unawaited(_connectToVmService(vmServiceUri)); @@ -97,8 +95,9 @@ // Ignore events that are not supported for the DevTools => Extension // direction. - if (!extensionEvent.type - .supportedForDirection(ExtensionEventDirection.toExtension)) { + if (!extensionEvent.type.supportedForDirection( + ExtensionEventDirection.toExtension, + )) { return; } @@ -110,8 +109,10 @@ ); break; case DevToolsExtensionEventType.vmServiceConnection: - final vmServiceUri = extensionEvent - .data?[ExtensionEventParameters.vmServiceConnectionUri] as String?; + final vmServiceUri = + extensionEvent.data?[ExtensionEventParameters + .vmServiceConnectionUri] + as String?; unawaited(_connectToVmService(vmServiceUri)); break; case DevToolsExtensionEventType.themeUpdate: @@ -206,10 +207,7 @@ try { await dtdManager.connect(Uri.parse(dtdUri)); - updateQueryParameter( - _dtdQueryParameter, - dtdManager.uri.toString(), - ); + updateQueryParameter(_dtdQueryParameter, dtdManager.uri.toString()); } catch (e) { final errorMessage = 'Unable to connect extension to the Dart Tooling Daemon at $dtdUri: $e'; @@ -219,7 +217,8 @@ } void _setThemeForValue(String? themeValue) { - final useDarkTheme = (themeValue == null && useDarkThemeAsDefault) || + final useDarkTheme = + (themeValue == null && useDarkThemeAsDefault) || themeValue == ExtensionEventParameters.themeValueDark; darkThemeEnabled.value = useDarkTheme; // Use a post frame callback so that we do not try to update this while a @@ -244,9 +243,7 @@ /// /// See also [ShowNotificationExtensionEvent]. void showNotification(String message) { - postMessageToDevTools( - ShowNotificationExtensionEvent(message: message), - ); + postMessageToDevTools(ShowNotificationExtensionEvent(message: message)); } /// Show a banner message in DevTools.
diff --git a/packages/devtools_extensions/test/api_test.dart b/packages/devtools_extensions/test/api_test.dart index f2b162d..acf8d79 100644 --- a/packages/devtools_extensions/test/api_test.dart +++ b/packages/devtools_extensions/test/api_test.dart
@@ -22,9 +22,7 @@ expect(event.type, DevToolsExtensionEventType.pong); expect(event.data, {'baz': 'bob'}); - event = DevToolsExtensionEvent.parse({ - 'type': 'idk', - }); + event = DevToolsExtensionEvent.parse({'type': 'idk'}); expect(event.type, DevToolsExtensionEventType.unknown); expect(event.data, isNull); }); @@ -124,42 +122,51 @@ }); test('supportedForDirection', () { - verifyEventDirection( - DevToolsExtensionEventType.ping, - (bidirectional: false, toDevTools: false, toExtension: true), - ); - verifyEventDirection( - DevToolsExtensionEventType.pong, - (bidirectional: false, toDevTools: true, toExtension: false), - ); - verifyEventDirection( - DevToolsExtensionEventType.forceReload, - (bidirectional: false, toDevTools: false, toExtension: true), - ); - verifyEventDirection( - DevToolsExtensionEventType.vmServiceConnection, - (bidirectional: true, toDevTools: true, toExtension: true), - ); - verifyEventDirection( - DevToolsExtensionEventType.themeUpdate, - (bidirectional: false, toDevTools: false, toExtension: true), - ); - verifyEventDirection( - DevToolsExtensionEventType.showNotification, - (bidirectional: false, toDevTools: true, toExtension: false), - ); - verifyEventDirection( - DevToolsExtensionEventType.showBannerMessage, - (bidirectional: false, toDevTools: true, toExtension: false), - ); - verifyEventDirection( - DevToolsExtensionEventType.copyToClipboard, - (bidirectional: false, toDevTools: true, toExtension: false), - ); - verifyEventDirection( - DevToolsExtensionEventType.unknown, - (bidirectional: true, toDevTools: true, toExtension: true), - ); + verifyEventDirection(DevToolsExtensionEventType.ping, ( + bidirectional: false, + toDevTools: false, + toExtension: true, + )); + verifyEventDirection(DevToolsExtensionEventType.pong, ( + bidirectional: false, + toDevTools: true, + toExtension: false, + )); + verifyEventDirection(DevToolsExtensionEventType.forceReload, ( + bidirectional: false, + toDevTools: false, + toExtension: true, + )); + verifyEventDirection(DevToolsExtensionEventType.vmServiceConnection, ( + bidirectional: true, + toDevTools: true, + toExtension: true, + )); + verifyEventDirection(DevToolsExtensionEventType.themeUpdate, ( + bidirectional: false, + toDevTools: false, + toExtension: true, + )); + verifyEventDirection(DevToolsExtensionEventType.showNotification, ( + bidirectional: false, + toDevTools: true, + toExtension: false, + )); + verifyEventDirection(DevToolsExtensionEventType.showBannerMessage, ( + bidirectional: false, + toDevTools: true, + toExtension: false, + )); + verifyEventDirection(DevToolsExtensionEventType.copyToClipboard, ( + bidirectional: false, + toDevTools: true, + toExtension: false, + )); + verifyEventDirection(DevToolsExtensionEventType.unknown, ( + bidirectional: true, + toDevTools: true, + toExtension: true, + )); }); }); @@ -167,9 +174,7 @@ test('constructs for expected values', () { final event = DevToolsExtensionEvent.parse({ 'type': 'showNotification', - 'data': { - 'message': 'foo message', - }, + 'data': {'message': 'foo message'}, }); final showNotificationEvent = ShowNotificationExtensionEvent.from(event); expect(showNotificationEvent.message, 'foo message'); @@ -181,12 +186,9 @@ // Missing required fields. }, }); - expect( - () { - ShowNotificationExtensionEvent.from(event1); - }, - throwsFormatException, - ); + expect(() { + ShowNotificationExtensionEvent.from(event1); + }, throwsFormatException); final event2 = DevToolsExtensionEvent.parse({ 'type': 'showNotification', @@ -195,12 +197,9 @@ 'msg': 'foo message', }, }); - expect( - () { - ShowNotificationExtensionEvent.from(event2); - }, - throwsFormatException, - ); + expect(() { + ShowNotificationExtensionEvent.from(event2); + }, throwsFormatException); final event3 = DevToolsExtensionEvent.parse({ 'type': 'showNotification', @@ -209,26 +208,18 @@ 'message': false, }, }); - expect( - () { - ShowNotificationExtensionEvent.from(event3); - }, - throwsFormatException, - ); + expect(() { + ShowNotificationExtensionEvent.from(event3); + }, throwsFormatException); final event4 = DevToolsExtensionEvent.parse({ // Wrong type. 'type': 'showBannerMessage', - 'data': { - 'message': 'foo message', - }, + 'data': {'message': 'foo message'}, }); - expect( - () { - ShowNotificationExtensionEvent.from(event4); - }, - throwsAssertionError, - ); + expect(() { + ShowNotificationExtensionEvent.from(event4); + }, throwsAssertionError); }); }); @@ -277,12 +268,9 @@ 'extensionName': 'foo', }, }); - expect( - () { - ShowBannerMessageExtensionEvent.from(event1); - }, - throwsFormatException, - ); + expect(() { + ShowBannerMessageExtensionEvent.from(event1); + }, throwsFormatException); final event2 = DevToolsExtensionEvent.parse({ 'type': 'showBannerMessage', @@ -294,12 +282,9 @@ 'extension_name': 'foo', }, }); - expect( - () { - ShowBannerMessageExtensionEvent.from(event2); - }, - throwsFormatException, - ); + expect(() { + ShowBannerMessageExtensionEvent.from(event2); + }, throwsFormatException); final event3 = DevToolsExtensionEvent.parse({ 'type': 'showBannerMessage', @@ -311,12 +296,9 @@ 'extensionName': 'foo', }, }); - expect( - () { - ShowBannerMessageExtensionEvent.from(event3); - }, - throwsFormatException, - ); + expect(() { + ShowBannerMessageExtensionEvent.from(event3); + }, throwsFormatException); final event4 = DevToolsExtensionEvent.parse({ // Wrong type. @@ -328,12 +310,9 @@ 'extensionName': 'foo', }, }); - expect( - () { - ShowBannerMessageExtensionEvent.from(event4); - }, - throwsAssertionError, - ); + expect(() { + ShowBannerMessageExtensionEvent.from(event4); + }, throwsAssertionError); }); }); @@ -341,10 +320,7 @@ test('constructs for expected values', () { final event = DevToolsExtensionEvent.parse({ 'type': 'copyToClipboard', - 'data': { - 'content': 'foo content', - 'successMessage': 'foo success', - }, + 'data': {'content': 'foo content', 'successMessage': 'foo success'}, }); final copyToClipboardEvent = CopyToClipboardExtensionEvent.from(event); expect(copyToClipboardEvent.content, 'foo content'); @@ -357,12 +333,9 @@ // Missing required fields. }, }); - expect( - () { - CopyToClipboardExtensionEvent.from(event1); - }, - throwsFormatException, - ); + expect(() { + CopyToClipboardExtensionEvent.from(event1); + }, throwsFormatException); final event2 = DevToolsExtensionEvent.parse({ 'type': 'copyToClipboard', @@ -372,12 +345,9 @@ 'successMessage': 'foo success', }, }); - expect( - () { - CopyToClipboardExtensionEvent.from(event2); - }, - throwsFormatException, - ); + expect(() { + CopyToClipboardExtensionEvent.from(event2); + }, throwsFormatException); final event3 = DevToolsExtensionEvent.parse({ 'type': 'copyToClipboard', @@ -387,27 +357,18 @@ 'successMessage': 'foo success', }, }); - expect( - () { - CopyToClipboardExtensionEvent.from(event3); - }, - throwsFormatException, - ); + expect(() { + CopyToClipboardExtensionEvent.from(event3); + }, throwsFormatException); final event4 = DevToolsExtensionEvent.parse({ // Wrong type. 'type': 'showBannerMessage', - 'data': { - 'content': 'foo content', - 'successMessage': 'foo success', - }, + 'data': {'content': 'foo content', 'successMessage': 'foo success'}, }); - expect( - () { - CopyToClipboardExtensionEvent.from(event4); - }, - throwsAssertionError, - ); + expect(() { + CopyToClipboardExtensionEvent.from(event4); + }, throwsAssertionError); }); }); }
diff --git a/packages/devtools_extensions/test/validate_test.dart b/packages/devtools_extensions/test/validate_test.dart index ec94dd1..8efcb5e 100644 --- a/packages/devtools_extensions/test/validate_test.dart +++ b/packages/devtools_extensions/test/validate_test.dart
@@ -10,10 +10,7 @@ void main() { final examplesWithExtensions = [ ( - relativePublishLocation: p.join( - '..', - 'dart_foo', - ), + relativePublishLocation: p.join('..', 'dart_foo'), sourceCodeLocation: p.join( 'example', 'packages_with_extensions', @@ -23,10 +20,7 @@ ), ), ( - relativePublishLocation: p.join( - '..', - 'foo', - ), + relativePublishLocation: p.join('..', 'foo'), sourceCodeLocation: p.join( 'example', 'packages_with_extensions', @@ -48,17 +42,13 @@ group('devtools_extensions validate command succeeds', () { for (final example in examplesWithExtensions) { test(example.relativePublishLocation, () async { - final p = await Process.run( - 'dart', - [ - 'run', - 'devtools_extensions', - 'validate', - '-p', - example.relativePublishLocation, - ], - workingDirectory: example.sourceCodeLocation, - ); + final p = await Process.run('dart', [ + 'run', + 'devtools_extensions', + 'validate', + '-p', + example.relativePublishLocation, + ], workingDirectory: example.sourceCodeLocation); expect(p.stderr, isEmpty); }); }
diff --git a/packages/devtools_extensions/test/web/devtools_extension_test.dart b/packages/devtools_extensions/test/web/devtools_extension_test.dart index 03fd446..15a4eda 100644 --- a/packages/devtools_extensions/test/web/devtools_extension_test.dart +++ b/packages/devtools_extensions/test/web/devtools_extension_test.dart
@@ -17,14 +17,13 @@ expect(() => dtdManager, throwsStateError); }); - testWidgets( - 'building $DevToolsExtension initializes globals', - (tester) async { - await tester.pumpWidget(const DevToolsExtension(child: SizedBox())); - expect(serviceManager, isNotNull); - expect(extensionManager, isNotNull); - expect(dtdManager, isNotNull); - }, - ); + testWidgets('building $DevToolsExtension initializes globals', ( + tester, + ) async { + await tester.pumpWidget(const DevToolsExtension(child: SizedBox())); + expect(serviceManager, isNotNull); + expect(extensionManager, isNotNull); + expect(dtdManager, isNotNull); + }); }); }
diff --git a/packages/devtools_shared/lib/src/common.dart b/packages/devtools_shared/lib/src/common.dart index bd99c66..fc08b32 100644 --- a/packages/devtools_shared/lib/src/common.dart +++ b/packages/devtools_shared/lib/src/common.dart
@@ -8,11 +8,8 @@ /// Information about a Dart Tooling Daemon instance. class DtdInfo { - DtdInfo( - this.localUri, { - Uri? exposedUri, - this.secret, - }) : exposedUri = exposedUri ?? localUri; + DtdInfo(this.localUri, {Uri? exposedUri, this.secret}) + : exposedUri = exposedUri ?? localUri; /// The URI for connecting to DTD from the backend. ///
diff --git a/packages/devtools_shared/lib/src/deeplink/app_link_settings.dart b/packages/devtools_shared/lib/src/deeplink/app_link_settings.dart index 87a62e1..9d9d21f 100644 --- a/packages/devtools_shared/lib/src/deeplink/app_link_settings.dart +++ b/packages/devtools_shared/lib/src/deeplink/app_link_settings.dart
@@ -39,22 +39,12 @@ factory AppLinkSettings.fromErrorJson(String json) { final jsonObject = jsonDecode(json) as Map; final message = jsonObject[_kErrorKey]! as String; - return AppLinkSettings._( - '', - false, - <AndroidDeeplink>[], - message, - ); + return AppLinkSettings._('', false, <AndroidDeeplink>[], message); } /// Used when the server can't retrieve app link settings. factory AppLinkSettings.error(String message) { - return AppLinkSettings._( - '', - false, - <AndroidDeeplink>[], - message, - ); + return AppLinkSettings._('', false, <AndroidDeeplink>[], message); } static const _kApplicationIdKey = 'applicationId';
diff --git a/packages/devtools_shared/lib/src/deeplink/deeplink_manager.dart b/packages/devtools_shared/lib/src/deeplink/deeplink_manager.dart index b395832..40aece3 100644 --- a/packages/devtools_shared/lib/src/deeplink/deeplink_manager.dart +++ b/packages/devtools_shared/lib/src/deeplink/deeplink_manager.dart
@@ -75,11 +75,7 @@ 'DASH__TOOL': ide != null ? _mapIdeToDashToolLabel(ide) : 'devtools', }; - return Process.run( - executable, - arguments, - environment: environment, - ); + return Process.run(executable, arguments, environment: environment); } String _mapIdeToDashToolLabel(String ide) { @@ -147,28 +143,22 @@ Map<String, Object?> _handleRunFlutterError( covariant _FlutterProcessError error, ) { - return <String, String?>{ - kErrorField: error.message, - }; + return <String, String?>{kErrorField: error.message}; } Future<Map<String, Object?>> _handleReadJsonFile(String filePath) { - return File(filePath) - .readAsString() - .then<Map<String, Object?>>(_handleJsonOutput); + return File( + filePath, + ).readAsString().then<Map<String, Object?>>(_handleJsonOutput); } Future<Map<String, Object?>> _handleJsonOutput(String jsonOutput) async { try { jsonEncode(jsonOutput); } on Error catch (e) { - return <String, String?>{ - kErrorField: e.toString(), - }; + return <String, String?>{kErrorField: e.toString()}; } - return <String, String?>{ - kOutputJsonField: jsonOutput, - }; + return <String, String?>{kOutputJsonField: jsonOutput}; } Future<Map<String, Object?>> getAndroidBuildVariants({
diff --git a/packages/devtools_shared/lib/src/deeplink/xcode_build_options.dart b/packages/devtools_shared/lib/src/deeplink/xcode_build_options.dart index 1298652..2e3352f 100644 --- a/packages/devtools_shared/lib/src/deeplink/xcode_build_options.dart +++ b/packages/devtools_shared/lib/src/deeplink/xcode_build_options.dart
@@ -10,8 +10,10 @@ XcodeBuildOptions._(jsonDecode(json)); /// Used when the the server can't retrieve ios build options. - static const empty = - XcodeBuildOptions._({_kConfigurationsKey: [], _kTargetsKey: []}); + static const empty = XcodeBuildOptions._({ + _kConfigurationsKey: [], + _kTargetsKey: [], + }); static const _kConfigurationsKey = 'configurations'; static const _kTargetsKey = 'targets';
diff --git a/packages/devtools_shared/lib/src/extensions/extension_enablement.dart b/packages/devtools_shared/lib/src/extensions/extension_enablement.dart index 4d0abaa..d6a1267 100644 --- a/packages/devtools_shared/lib/src/extensions/extension_enablement.dart +++ b/packages/devtools_shared/lib/src/extensions/extension_enablement.dart
@@ -16,7 +16,8 @@ static const _extensionsKey = 'extensions'; static const _descriptionKey = 'description'; static const _documentationKey = 'documentation'; - static const _defaultOptions = ''' + static const _defaultOptions = + ''' $_descriptionKey: This file stores settings for Dart & Flutter DevTools. $_documentationKey: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states $_extensionsKey: @@ -36,8 +37,8 @@ final options = _optionsAsMap(optionsUri: devtoolsOptionsUri); if (options == null) return ExtensionEnabledState.error; - final extensions = - (options[_extensionsKey] as List?)?.cast<Map<String, Object?>>(); + final extensions = (options[_extensionsKey] as List?) + ?.cast<Map<String, Object?>>(); if (extensions == null) return ExtensionEnabledState.none; for (final e in extensions) { @@ -65,8 +66,8 @@ final options = _optionsAsMap(optionsUri: devtoolsOptionsUri); if (options == null) return ExtensionEnabledState.error; - var extensions = - (options[_extensionsKey] as List?)?.cast<Map<String, Object?>>(); + var extensions = (options[_extensionsKey] as List?) + ?.cast<Map<String, Object?>>(); if (extensions == null) { options[_extensionsKey] = <Map<String, Object?>>[]; extensions = options[_extensionsKey] as List<Map<String, Object?>>; @@ -111,10 +112,9 @@ }) { final yamlEditor = YamlEditor(''); yamlEditor.update([], options); - _lookupOptionsFile(optionsUri)?.writeAsStringSync( - yamlEditor.toString(), - flush: true, - ); + _lookupOptionsFile( + optionsUri, + )?.writeAsStringSync(yamlEditor.toString(), flush: true); } /// Returns the `devtools_options.yaml` file at [optionsUri].
diff --git a/packages/devtools_shared/lib/src/extensions/extension_manager.dart b/packages/devtools_shared/lib/src/extensions/extension_manager.dart index 7df4cee..92ad601 100644 --- a/packages/devtools_shared/lib/src/extensions/extension_manager.dart +++ b/packages/devtools_shared/lib/src/extensions/extension_manager.dart
@@ -150,9 +150,10 @@ final config = extension.config; // TODO(https://github.com/dart-lang/pub/issues/4042): make this check // more robust. - final isPubliclyHosted = (extension.rootUri.path.contains('pub.dev') || - extension.rootUri.path.contains('pub.flutter-io.cn')) - .toString(); + final isPubliclyHosted = + (extension.rootUri.path.contains('pub.dev') || + extension.rootUri.path.contains('pub.flutter-io.cn')) + .toString(); // This should be relative to the 'extension/devtools/' directory and // defaults to 'build'; @@ -179,8 +180,8 @@ devtoolsOptionsFileName, ), DevToolsExtensionConfig.isPubliclyHostedKey: isPubliclyHosted, - DevToolsExtensionConfig.detectedFromStaticContextKey: - staticContext.toString(), + DevToolsExtensionConfig.detectedFromStaticContextKey: staticContext + .toString(), }); devtoolsExtensions.add(extensionConfig); } on StateError catch (e) {
diff --git a/packages/devtools_shared/lib/src/extensions/extension_model.dart b/packages/devtools_shared/lib/src/extensions/extension_model.dart index e1630de..8d669e0 100644 --- a/packages/devtools_shared/lib/src/extensions/extension_model.dart +++ b/packages/devtools_shared/lib/src/extensions/extension_model.dart
@@ -32,24 +32,23 @@ final requiresConnection = requiresConnectionValue != false && requiresConnectionValue != 'false'; - if (json - case { - // The exptected keys below are required fields in the extension's - // config.yaml file. - nameKey: final String name, - issueTrackerKey: final String issueTracker, - versionKey: final String version, - materialIconCodePointKey: final Object codePointFromJson, - // The expected keys below are not from the extension's config.yaml - // file; they are generated during the extension detection mechanism - // in the DevTools server. - extensionAssetsPathKey: final String extensionAssetsPath, - devtoolsOptionsUriKey: final String devtoolsOptionsUri, - isPubliclyHostedKey: final String isPubliclyHosted, - detectedFromStaticContextKey: final String detectedFromStaticContext, - // Note that the field [requiresConnectionKey] is not required for - // this check because it is optional. - }) { + if (json case { + // The exptected keys below are required fields in the extension's + // config.yaml file. + nameKey: final String name, + issueTrackerKey: final String issueTracker, + versionKey: final String version, + materialIconCodePointKey: final Object codePointFromJson, + // The expected keys below are not from the extension's config.yaml + // file; they are generated during the extension detection mechanism + // in the DevTools server. + extensionAssetsPathKey: final String extensionAssetsPath, + devtoolsOptionsUriKey: final String devtoolsOptionsUri, + isPubliclyHostedKey: final String isPubliclyHosted, + detectedFromStaticContextKey: final String detectedFromStaticContext, + // Note that the field [requiresConnectionKey] is not required for + // this check because it is optional. + }) { final underscoresAndLetters = RegExp(r'^[a-z0-9_]*$'); if (!underscoresAndLetters.hasMatch(name)) { throw StateError( @@ -88,13 +87,8 @@ } else { _assertGeneratedKeysPresent(json); final jsonKeysFromConfigFile = Set.of(json.keys.toSet()) - ..removeAll([ - ..._serverGeneratedKeys, - ..._optionalKeys, - ]); - final diff = _requiredKeys.toSet().difference( - jsonKeysFromConfigFile, - ); + ..removeAll([..._serverGeneratedKeys, ..._optionalKeys]); + final diff = _requiredKeys.toSet().difference(jsonKeysFromConfigFile); if (diff.isNotEmpty) { throw StateError( 'Missing required fields ${diff.toString()} in the extension ' @@ -241,16 +235,16 @@ String get analyticsSafeName => isPubliclyHosted ? name : 'private'; Map<String, Object?> toJson() => { - nameKey: name, - issueTrackerKey: issueTrackerLink, - versionKey: version, - materialIconCodePointKey: materialIconCodePoint, - requiresConnectionKey: requiresConnection.toString(), - extensionAssetsPathKey: extensionAssetsPath, - devtoolsOptionsUriKey: devtoolsOptionsUri, - isPubliclyHostedKey: isPubliclyHosted.toString(), - detectedFromStaticContextKey: detectedFromStaticContext.toString(), - }; + nameKey: name, + issueTrackerKey: issueTrackerLink, + versionKey: version, + materialIconCodePointKey: materialIconCodePoint, + requiresConnectionKey: requiresConnection.toString(), + extensionAssetsPathKey: extensionAssetsPath, + devtoolsOptionsUriKey: devtoolsOptionsUri, + isPubliclyHostedKey: isPubliclyHosted.toString(), + detectedFromStaticContextKey: detectedFromStaticContext.toString(), + }; @override int compareTo(DevToolsExtensionConfig other) { @@ -280,16 +274,16 @@ @override int get hashCode => Object.hash( - name, - issueTrackerLink, - version, - materialIconCodePoint, - requiresConnection, - extensionAssetsPath, - devtoolsOptionsUri, - isPubliclyHosted, - detectedFromStaticContext, - ); + name, + issueTrackerLink, + version, + materialIconCodePoint, + requiresConnection, + extensionAssetsPath, + devtoolsOptionsUri, + isPubliclyHosted, + detectedFromStaticContext, + ); static void _assertGeneratedKeysPresent(Map<String, Object?> json) { final missingKeys = <String>[]; @@ -325,8 +319,9 @@ /// Parses [value] and returns the matching [ExtensionEnabledState] if found. static ExtensionEnabledState from(String? value) { - return ExtensionEnabledState.values - .firstWhereOrNull((e) => e.name == value) ?? + return ExtensionEnabledState.values.firstWhereOrNull( + (e) => e.name == value, + ) ?? ExtensionEnabledState.none; } }
diff --git a/packages/devtools_shared/lib/src/memory/adb_memory_info.dart b/packages/devtools_shared/lib/src/memory/adb_memory_info.dart index 3e65031..9487526 100644 --- a/packages/devtools_shared/lib/src/memory/adb_memory_info.dart +++ b/packages/devtools_shared/lib/src/memory/adb_memory_info.dart
@@ -23,16 +23,16 @@ /// then the data is in kilobytes. See the factory constructor /// [AdbMemoryInfo.fromJsonInKB]. factory AdbMemoryInfo.fromJson(Map<String, Object?> json) => AdbMemoryInfo( - json[realTimeKey] as int, - json[javaHeapKey] as int, - json[nativeHeapKey] as int, - json[codeKey] as int, - json[stackKey] as int, - json[graphicsKey] as int, - json[otherKey] as int, - json[systemKey] as int, - json[totalKey] as int, - ); + json[realTimeKey] as int, + json[javaHeapKey] as int, + json[nativeHeapKey] as int, + json[codeKey] as int, + json[stackKey] as int, + json[graphicsKey] as int, + json[otherKey] as int, + json[systemKey] as int, + json[totalKey] as int, + ); /// Use when converting data received from the service extension, /// directly from ADB. All data received from ADB dumpsys meminfo is @@ -85,16 +85,16 @@ @override Map<String, dynamic> toJson() => <String, Object?>{ - realTimeKey: realtime, - javaHeapKey: javaHeap, - nativeHeapKey: nativeHeap, - codeKey: code, - stackKey: stack, - graphicsKey: graphics, - otherKey: other, - systemKey: system, - totalKey: total, - }; + realTimeKey: realtime, + javaHeapKey: javaHeap, + nativeHeapKey: nativeHeap, + codeKey: code, + stackKey: stack, + graphicsKey: graphics, + otherKey: other, + systemKey: system, + totalKey: total, + }; /// Create an empty [AdbMemoryInfo], where all values are 0. static AdbMemoryInfo empty() => AdbMemoryInfo(0, 0, 0, 0, 0, 0, 0, 0, 0); @@ -130,7 +130,8 @@ Duration get bootDuration => Duration(milliseconds: realtime); @override - String toString() => '[AdbMemoryInfo ' + String toString() => + '[AdbMemoryInfo ' '$realTimeKey: $realtime, ' 'realtimeDT: $realtimeDT, ' 'durationBoot: $bootDuration, '
diff --git a/packages/devtools_shared/lib/src/memory/class_heap_detail_stats.dart b/packages/devtools_shared/lib/src/memory/class_heap_detail_stats.dart index 7e15120..6990959 100644 --- a/packages/devtools_shared/lib/src/memory/class_heap_detail_stats.dart +++ b/packages/devtools_shared/lib/src/memory/class_heap_detail_stats.dart
@@ -13,11 +13,11 @@ required int instances, int deltaInstances = 0, bool traceAllocations = false, - }) : bytesCurrent = bytes, - bytesDelta = deltaBytes, - instancesCurrent = instances, - instancesDelta = deltaInstances, - isStacktraced = traceAllocations; + }) : bytesCurrent = bytes, + bytesDelta = deltaBytes, + instancesCurrent = instances, + instancesDelta = deltaInstances, + isStacktraced = traceAllocations; factory ClassHeapDetailStats.fromJson(Map<String, Object?> json) { final {'id': classId, 'name': className} = json['class'] as Map; @@ -33,16 +33,13 @@ } Map<String, dynamic> toJson() => { - 'class': { - 'id': classRef.id, - 'name': classRef.name, - }, - 'bytesCurrent': bytesCurrent, - 'bytesDelta': bytesDelta, - 'instancesCurrent': instancesCurrent, - 'instancesDelta': instancesDelta, - 'isStackedTraced': isStacktraced, - }; + 'class': {'id': classRef.id, 'name': classRef.name}, + 'bytesCurrent': bytesCurrent, + 'bytesDelta': bytesDelta, + 'instancesCurrent': instancesCurrent, + 'instancesDelta': instancesDelta, + 'isStackedTraced': isStacktraced, + }; /// Version of [ClassHeapDetailStats] payload. static const version = 1; @@ -60,6 +57,7 @@ bool isStacktraced; @override - String toString() => '[ClassHeapDetailStats class: ${classRef.name}, ' + String toString() => + '[ClassHeapDetailStats class: ${classRef.name}, ' 'count: $instancesCurrent, bytes: $bytesCurrent]'; }
diff --git a/packages/devtools_shared/lib/src/memory/event_sample.dart b/packages/devtools_shared/lib/src/memory/event_sample.dart index 1234452..b51a12b 100644 --- a/packages/devtools_shared/lib/src/memory/event_sample.dart +++ b/packages/devtools_shared/lib/src/memory/event_sample.dart
@@ -19,17 +19,17 @@ AllocationAccumulator(this._start, this._continues, this._reset); AllocationAccumulator.start() - : _start = true, - _continues = false, - _reset = false; + : _start = true, + _continues = false, + _reset = false; AllocationAccumulator.continues() - : _start = false, - _continues = true, - _reset = false; + : _start = false, + _continues = true, + _reset = false; AllocationAccumulator.reset() - : _start = false, - _continues = false, - _reset = true; + : _start = false, + _continues = false, + _reset = true; factory AllocationAccumulator.fromJson(Map<String, Object?> json) => AllocationAccumulator( @@ -39,10 +39,10 @@ ); Map<String, dynamic> toJson() => <String, Object?>{ - 'start': _start, - 'continues': _continues, - 'reset': _reset, - }; + 'start': _start, + 'continues': _continues, + 'reset': _reset, + }; static AllocationAccumulator empty() => AllocationAccumulator(false, false, false); @@ -64,13 +64,14 @@ bool get isReset => _reset; @override - String toString() => '[AllocationAccumulator ' + String toString() => + '[AllocationAccumulator ' '${const JsonEncoder.withIndent(' ').convert(toJson())}]'; } class ExtensionEvent { ExtensionEvent(this.timestamp, this.eventKind, this.data) - : customEventName = null; + : customEventName = null; ExtensionEvent.custom( this.timestamp, @@ -88,11 +89,11 @@ ); Map<String, dynamic> toJson() => <String, Object?>{ - 'timestamp': timestamp, - 'eventKind': eventKind, - 'data': data, - 'customEventName': customEventName, - }; + 'timestamp': timestamp, + 'eventKind': eventKind, + 'data': data, + 'customEventName': customEventName, + }; static ExtensionEvent empty() => ExtensionEvent.custom(null, null, null, null); @@ -112,7 +113,8 @@ final String? customEventName; @override - String toString() => '[ExtensionEvent ' + String toString() => + '[ExtensionEvent ' '${const JsonEncoder.withIndent(' ').convert(toJson())}]'; } @@ -152,7 +154,8 @@ void clear() => events.clear(); @override - String toString() => '[ExtensionEvents = ' + String toString() => + '[ExtensionEvents = ' '${const JsonEncoder.withIndent(' ').convert(toJson())}]'; } @@ -167,58 +170,52 @@ ); EventSample.gcEvent(this.timestamp, {ExtensionEvents? events}) - : isEventGC = true, - isEventSnapshot = false, - isEventSnapshotAuto = false, - allocationAccumulator = null, - extensionEvents = events; + : isEventGC = true, + isEventSnapshot = false, + isEventSnapshotAuto = false, + allocationAccumulator = null, + extensionEvents = events; EventSample.snapshotEvent( this.timestamp, { bool snapshotAuto = false, ExtensionEvents? events, - }) : isEventGC = false, - isEventSnapshot = !snapshotAuto, - isEventSnapshotAuto = snapshotAuto, - allocationAccumulator = null, - extensionEvents = events; + }) : isEventGC = false, + isEventSnapshot = !snapshotAuto, + isEventSnapshotAuto = snapshotAuto, + allocationAccumulator = null, + extensionEvents = events; - EventSample.accumulatorStart( - this.timestamp, { - ExtensionEvents? events, - }) : isEventGC = false, - isEventSnapshot = false, - isEventSnapshotAuto = false, - allocationAccumulator = AllocationAccumulator.start(), - extensionEvents = events; + EventSample.accumulatorStart(this.timestamp, {ExtensionEvents? events}) + : isEventGC = false, + isEventSnapshot = false, + isEventSnapshotAuto = false, + allocationAccumulator = AllocationAccumulator.start(), + extensionEvents = events; - EventSample.accumulatorContinues( - this.timestamp, { - ExtensionEvents? events, - }) : isEventGC = false, - isEventSnapshot = false, - isEventSnapshotAuto = false, - allocationAccumulator = AllocationAccumulator.continues(), - extensionEvents = events; + EventSample.accumulatorContinues(this.timestamp, {ExtensionEvents? events}) + : isEventGC = false, + isEventSnapshot = false, + isEventSnapshotAuto = false, + allocationAccumulator = AllocationAccumulator.continues(), + extensionEvents = events; - EventSample.accumulatorReset( - this.timestamp, { - ExtensionEvents? events, - }) : isEventGC = false, - isEventSnapshot = false, - isEventSnapshotAuto = false, - allocationAccumulator = AllocationAccumulator.reset(), - extensionEvents = events; + EventSample.accumulatorReset(this.timestamp, {ExtensionEvents? events}) + : isEventGC = false, + isEventSnapshot = false, + isEventSnapshotAuto = false, + allocationAccumulator = AllocationAccumulator.reset(), + extensionEvents = events; EventSample.extensionEvent(this.timestamp, this.extensionEvents) - : isEventGC = false, - isEventSnapshot = false, - isEventSnapshotAuto = false, - allocationAccumulator = null; + : isEventGC = false, + isEventSnapshot = false, + isEventSnapshotAuto = false, + allocationAccumulator = null; factory EventSample.fromJson(Map<String, Object?> json) { - final extensionEvents = - (json['extensionEvents'] as Map?)?.cast<String, Object>(); + final extensionEvents = (json['extensionEvents'] as Map?) + ?.cast<String, Object>(); return EventSample( json['timestamp'] as int, @@ -238,13 +235,13 @@ @override Map<String, dynamic> toJson() => <String, Object?>{ - 'timestamp': timestamp, - 'gcEvent': isEventGC, - 'snapshotEvent': isEventSnapshot, - 'snapshotAutoEvent': isEventSnapshotAuto, - 'allocationAccumulatorEvent': allocationAccumulator?.toJson(), - 'extensionEvents': extensionEvents?.toJson(), - }; + 'timestamp': timestamp, + 'gcEvent': isEventGC, + 'snapshotEvent': isEventSnapshot, + 'snapshotAutoEvent': isEventSnapshotAuto, + 'allocationAccumulatorEvent': allocationAccumulator?.toJson(), + 'extensionEvents': extensionEvents?.toJson(), + }; EventSample clone(int timestamp, {ExtensionEvents? extensionEvents}) => EventSample( @@ -257,14 +254,8 @@ ); /// Create an empty event (all values are nothing). - static EventSample empty() => EventSample( - -1, - false, - false, - false, - AllocationAccumulator.empty(), - null, - ); + static EventSample empty() => + EventSample(-1, false, false, false, AllocationAccumulator.empty(), null); bool get isEmpty => timestamp == -1; @@ -288,7 +279,8 @@ final ExtensionEvents? extensionEvents; @override - String toString() => '[EventSample timestamp: $timestamp = ' + String toString() => + '[EventSample timestamp: $timestamp = ' '${const JsonEncoder.withIndent(' ').convert(toJson())}]'; } @@ -314,11 +306,12 @@ @override Map<String, dynamic> toJson() => <String, Object?>{ - 'layerBytes': layerBytes, - 'pictureBytes': pictureBytes, - }; + 'layerBytes': layerBytes, + 'pictureBytes': pictureBytes, + }; @override - String toString() => '[RasterCache ' + String toString() => + '[RasterCache ' '${const JsonEncoder.withIndent(' ').convert(toJson())}]'; }
diff --git a/packages/devtools_shared/lib/src/memory/heap_sample.dart b/packages/devtools_shared/lib/src/memory/heap_sample.dart index 5248072..8ba0e85 100644 --- a/packages/devtools_shared/lib/src/memory/heap_sample.dart +++ b/packages/devtools_shared/lib/src/memory/heap_sample.dart
@@ -41,9 +41,9 @@ AdbMemoryInfo? adbMemoryInfo, EventSample? memoryEventInfo, RasterCache? rasterCache, - ) : adbMemoryInfo = adbMemoryInfo ?? AdbMemoryInfo.empty(), - memoryEventInfo = memoryEventInfo ?? EventSample.empty(), - rasterCache = rasterCache ?? RasterCache.empty(); + ) : adbMemoryInfo = adbMemoryInfo ?? AdbMemoryInfo.empty(), + memoryEventInfo = memoryEventInfo ?? EventSample.empty(), + rasterCache = rasterCache ?? RasterCache.empty(); factory HeapSample.fromJson(Map<String, Object?> json) { return HeapSample( @@ -72,16 +72,16 @@ @override Map<String, dynamic> toJson() => <String, Object?>{ - Json.timestamp.key: timestamp, - Json.rss.key: rss, - Json.capacity.key: capacity, - Json.used.key: used, - Json.external.key: external, - Json.gc.key: isGC, - Json.adbMemoryInfo.key: adbMemoryInfo, - Json.memoryEventInfo.key: memoryEventInfo, - Json.rasterCache.key: rasterCache, - }; + Json.timestamp.key: timestamp, + Json.rss.key: rss, + Json.capacity.key: capacity, + Json.used.key: used, + Json.external.key: external, + Json.gc.key: isGC, + Json.adbMemoryInfo.key: adbMemoryInfo, + Json.memoryEventInfo.key: memoryEventInfo, + Json.rasterCache.key: rasterCache, + }; /// Version of HeapSample JSON payload. static const version = 1; @@ -105,6 +105,7 @@ RasterCache rasterCache; @override - String toString() => '[HeapSample timestamp: $timestamp, ' + String toString() => + '[HeapSample timestamp: $timestamp, ' '${const JsonEncoder.withIndent(' ').convert(toJson())}]'; }
diff --git a/packages/devtools_shared/lib/src/memory/heap_space.dart b/packages/devtools_shared/lib/src/memory/heap_space.dart index 9c45586..b0e0335 100644 --- a/packages/devtools_shared/lib/src/memory/heap_space.dart +++ b/packages/devtools_shared/lib/src/memory/heap_space.dart
@@ -5,14 +5,13 @@ /// HeapSpace of Dart VM collected heap data. class HeapSpace { HeapSpace._fromJson(this.json) - : avgCollectionPeriodMillis = - json['avgCollectionPeriodMillis'] as double?, - capacity = json['capacity'] as int?, - collections = json['collections'] as int?, - external = json['external'] as int?, - name = json['name'] as String?, - time = json['time'] as double?, - used = json['used'] as int?; + : avgCollectionPeriodMillis = json['avgCollectionPeriodMillis'] as double?, + capacity = json['capacity'] as int?, + collections = json['collections'] as int?, + external = json['external'] as int?, + name = json['name'] as String?, + time = json['time'] as double?, + used = json['used'] as int?; static HeapSpace? parse(Map<String, Object?>? json) => json == null ? null : HeapSpace._fromJson(json); @@ -34,15 +33,15 @@ final int? used; Map<String, dynamic> toJson() => <String, Object?>{ - 'type': 'HeapSpace', - 'avgCollectionPeriodMillis': avgCollectionPeriodMillis, - 'capacity': capacity, - 'collections': collections, - 'external': external, - 'name': name, - 'time': time, - 'used': used, - }; + 'type': 'HeapSpace', + 'avgCollectionPeriodMillis': avgCollectionPeriodMillis, + 'capacity': capacity, + 'collections': collections, + 'external': external, + 'name': name, + 'time': time, + 'used': used, + }; @override String toString() => '[HeapSpace]';
diff --git a/packages/devtools_shared/lib/src/memory/memory_json.dart b/packages/devtools_shared/lib/src/memory/memory_json.dart index 9607c65..4b78fd7 100644 --- a/packages/devtools_shared/lib/src/memory/memory_json.dart +++ b/packages/devtools_shared/lib/src/memory/memory_json.dart
@@ -97,10 +97,10 @@ required String argJsonString, Map<String, Object?>? argDecodedMap, }) : super.decode( - _jsonMemoryPayloadField, - argJsonString: argJsonString, - argDecodedMap: argDecodedMap, - ); + _jsonMemoryPayloadField, + argJsonString: argJsonString, + argDecodedMap: argDecodedMap, + ); /// Exported JSON payload of collected memory statistics. static const _jsonMemoryPayloadField = 'samples'; @@ -180,10 +180,9 @@ Map<String, dynamic> upgradeToVersion( Map<String, Object?> payload, int oldVersion, - ) => - throw UnimplementedError( - '${HeapSample.version} is the only valid HeapSample version', - ); + ) => throw UnimplementedError( + '${HeapSample.version} is the only valid HeapSample version', + ); /// Given a list of [HeapSample], encode as a Json string. static String encodeList(List<HeapSample> data) { @@ -201,7 +200,8 @@ return '$header$result${MemoryJson.trailer}'; } - static String get header => '{"$_jsonMemoryPayloadField": {' + static String get header => + '{"$_jsonMemoryPayloadField": {' '"${MemoryJson.jsonVersionField}": ${HeapSample.version}, ' '"${MemoryJson.jsonDevToolsScreenField}": "${MemoryJson.devToolsScreenValueMemory}", ' '"${MemoryJson.jsonDataField}": [\n'; @@ -272,10 +272,10 @@ required String argJsonString, Map<String, Object?>? argDecodedMap, }) : super.decode( - _jsonAllocationPayloadField, - argJsonString: argJsonString, - argDecodedMap: argDecodedMap, - ); + _jsonAllocationPayloadField, + argJsonString: argJsonString, + argDecodedMap: argDecodedMap, + ); /// Exported JSON payload of collected memory statistics. static const _jsonAllocationPayloadField = 'allocations'; @@ -308,10 +308,7 @@ for (final data in oldData) { 'type': 'ClassHeapStats', - 'class': <String, Object?>{ - 'type': '@Class', - ...data.class_, - }, + 'class': <String, Object?>{'type': '@Class', ...data.class_}, 'bytesCurrent': data.bytesCurrent, 'accumulatedSize': data.bytesDelta, 'instancesCurrent': data.instancesCurrent, @@ -355,7 +352,8 @@ } /// Allocations Header portion: - static String get header => '{"$_jsonAllocationPayloadField": {' + static String get header => + '{"$_jsonAllocationPayloadField": {' '"${MemoryJson.jsonVersionField}": $allocationFormatVersion, ' '"${MemoryJson.jsonDevToolsScreenField}": "${MemoryJson.devToolsScreenValueMemory}", ' '"${MemoryJson.jsonDataField}": [\n';
diff --git a/packages/devtools_shared/lib/src/server/devtools_store.dart b/packages/devtools_shared/lib/src/server/devtools_store.dart index 00f9558..5efdf5d 100644 --- a/packages/devtools_shared/lib/src/server/devtools_store.dart +++ b/packages/devtools_shared/lib/src/server/devtools_store.dart
@@ -88,8 +88,8 @@ /// The active survey in [properties], as a [_ActiveSurveyJson]. _ActiveSurveyJson get _activeSurveyFromProperties => _ActiveSurveyJson( - (properties[activeSurvey!] as Map).cast<String, Object?>(), - ); + (properties[activeSurvey!] as Map).cast<String, Object?>(), + ); int get surveyShownCount { assert(activeSurvey != null); @@ -104,10 +104,7 @@ assert(activeSurvey != null); surveyShownCount; // Ensure surveyShownCount has been initialized. final prop = _activeSurveyFromProperties; - rewriteActiveSurvey( - prop.surveyActionTaken, - prop.surveyShownCount! + 1, - ); + rewriteActiveSurvey(prop.surveyActionTaken, prop.surveyShownCount! + 1); } bool get surveyActionTaken { @@ -115,10 +112,7 @@ } set surveyActionTaken(bool value) { - rewriteActiveSurvey( - value, - _activeSurveyFromProperties.surveyShownCount!, - ); + rewriteActiveSurvey(value, _activeSurveyFromProperties.surveyShownCount!); } String get lastReleaseNotesVersion {
diff --git a/packages/devtools_shared/lib/src/server/file_system.dart b/packages/devtools_shared/lib/src/server/file_system.dart index 1f79c0f..6a2036f 100644 --- a/packages/devtools_shared/lib/src/server/file_system.dart +++ b/packages/devtools_shared/lib/src/server/file_system.dart
@@ -93,10 +93,7 @@ } class IOPersistentProperties { - IOPersistentProperties( - this.name, { - String? documentDirPath, - }) { + IOPersistentProperties(this.name, {String? documentDirPath}) { final fileName = name.replaceAll(' ', '_'); documentDirPath ??= LocalFileSystem._userHomeDir(); _file = File(path.join(documentDirPath, fileName));
diff --git a/packages/devtools_shared/lib/src/server/handlers/_deeplink.dart b/packages/devtools_shared/lib/src/server/handlers/_deeplink.dart index 42d05ec..b3d75e1 100644 --- a/packages/devtools_shared/lib/src/server/handlers/_deeplink.dart +++ b/packages/devtools_shared/lib/src/server/handlers/_deeplink.dart
@@ -113,9 +113,7 @@ if (error != null) { return api.serverError(error); } - return api.success( - result[DeeplinkManager.kOutputJsonField]! as String, - ); + return api.success(result[DeeplinkManager.kOutputJsonField]! as String); } }
diff --git a/packages/devtools_shared/lib/src/server/handlers/_devtools_extensions.dart b/packages/devtools_shared/lib/src/server/handlers/_devtools_extensions.dart index f7c6367..c01b8cc 100644 --- a/packages/devtools_shared/lib/src/server/handlers/_devtools_extensions.dart +++ b/packages/devtools_shared/lib/src/server/handlers/_devtools_extensions.dart
@@ -28,8 +28,9 @@ /// Helper to return a success response with all available extensions /// detected by [extensionsManager]. shelf.Response succeedWithAvailableExtensions({String? warning}) { - final extensions = - extensionsManager.devtoolsExtensions.map((p) => p.toJson()).toList(); + final extensions = extensionsManager.devtoolsExtensions + .map((p) => p.toJson()) + .toList(); result[ExtensionsApi.extensionsResultPropertyName] = extensions; if (warning != null) { result[ExtensionsApi.extensionsResultWarningPropertyName] = warning; @@ -91,11 +92,11 @@ ); return ServerApi._encodeResponse(newState.name, api: api); } - final activationState = - ServerApi._devToolsOptions.lookupExtensionEnabledState( - devtoolsOptionsUri: devtoolsOptionsFileUri, - extensionName: extensionName, - ); + final activationState = ServerApi._devToolsOptions + .lookupExtensionEnabledState( + devtoolsOptionsUri: devtoolsOptionsFileUri, + extensionName: extensionName, + ); return ServerApi._encodeResponse(activationState.name, api: api); } }
diff --git a/packages/devtools_shared/lib/src/server/handlers/_dtd.dart b/packages/devtools_shared/lib/src/server/handlers/_dtd.dart index b7f381b..f5e8c2f 100644 --- a/packages/devtools_shared/lib/src/server/handlers/_dtd.dart +++ b/packages/devtools_shared/lib/src/server/handlers/_dtd.dart
@@ -6,16 +6,10 @@ /// A namespace for Dart Tooling Daemon (DTD) server request handlers. extension _DtdApiHandler on Never { - static shelf.Response handleGetDtdUri( - ServerApi api, - DtdInfo? dtd, - ) { - return ServerApi._encodeResponse( - { - // Always provide the exposed URI to callers of the web API. - DtdApi.uriPropertyName: dtd?.exposedUri.toString(), - }, - api: api, - ); + static shelf.Response handleGetDtdUri(ServerApi api, DtdInfo? dtd) { + return ServerApi._encodeResponse({ + // Always provide the exposed URI to callers of the web API. + DtdApi.uriPropertyName: dtd?.exposedUri.toString(), + }, api: api); } }
diff --git a/packages/devtools_shared/lib/src/server/handlers/_vm_service.dart b/packages/devtools_shared/lib/src/server/handlers/_vm_service.dart index 2097bf9..94fd867 100644 --- a/packages/devtools_shared/lib/src/server/handlers/_vm_service.dart +++ b/packages/devtools_shared/lib/src/server/handlers/_vm_service.dart
@@ -130,7 +130,8 @@ if (root == null) { return ( success: false, - message: 'No root library found for main isolate ' + message: + 'No root library found for main isolate ' '($vmServiceUriAsString).', uri: null, ); @@ -168,8 +169,8 @@ required bool connected, required ServerApi api, }) async { - final currentRoots = - (await dtd.getIDEWorkspaceRoots()).ideWorkspaceRoots.toSet(); + final currentRoots = (await dtd.getIDEWorkspaceRoots()).ideWorkspaceRoots + .toSet(); // Add or remove [rootFromVmService] depending on whether this was a // connect or disconnect notification. final newRoots = connected @@ -195,10 +196,9 @@ final rootLib = mainIsolate.rootLib?.uri; if (rootLib == null) return null; - final fileUriAsString = - (await lookupResolvedPackageUris(mainIsolate.id!, [rootLib])) - .uris - ?.first; + final fileUriAsString = (await lookupResolvedPackageUris(mainIsolate.id!, [ + rootLib, + ])).uris?.first; return fileUriAsString; } @@ -218,8 +218,9 @@ Isolate? mainIsolate; for (final isolate in isolateCandidates) { - final isFlutterIsolate = (isolate.isolate.extensionRPCs ?? []) - .any((ext) => ext.startsWith('ext.flutter')); + final isFlutterIsolate = (isolate.isolate.extensionRPCs ?? []).any( + (ext) => ext.startsWith('ext.flutter'), + ); if (isFlutterIsolate) { mainIsolate = isolate.isolate; break; @@ -237,8 +238,4 @@ } @visibleForTesting -typedef DetectRootPackageResponse = ({ - bool success, - String? message, - Uri? uri, -}); +typedef DetectRootPackageResponse = ({bool success, String? message, Uri? uri});
diff --git a/packages/devtools_shared/lib/src/service/service.dart b/packages/devtools_shared/lib/src/service/service.dart index 91db01f..00fadb0 100644 --- a/packages/devtools_shared/lib/src/service/service.dart +++ b/packages/devtools_shared/lib/src/service/service.dart
@@ -69,13 +69,10 @@ return service; } unawaited( - ws.sink.done.then( - (_) async { - finishedCompleter.complete(); - await service.dispose(); - }, - onError: onError, - ), + ws.sink.done.then((_) async { + finishedCompleter.complete(); + await service.dispose(); + }, onError: onError), ); return service; } @@ -113,15 +110,19 @@ return service; } - unawaited(connectHelper().then( - (service) => connectedCompleter.safeComplete(service), - onError: onError, - )); - unawaited(finishedCompleter.future.then((_) { - // It is an error if we finish before we are connected. - if (!connectedCompleter.isCompleted) { - onError(null); - } - })); + unawaited( + connectHelper().then( + (service) => connectedCompleter.safeComplete(service), + onError: onError, + ), + ); + unawaited( + finishedCompleter.future.then((_) { + // It is an error if we finish before we are connected. + if (!connectedCompleter.isCompleted) { + onError(null); + } + }), + ); return connectedCompleter.future; }
diff --git a/packages/devtools_shared/lib/src/service_utils.dart b/packages/devtools_shared/lib/src/service_utils.dart index 8d8de24..5abe740 100644 --- a/packages/devtools_shared/lib/src/service_utils.dart +++ b/packages/devtools_shared/lib/src/service_utils.dart
@@ -3,10 +3,7 @@ // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. class RegisteredService { - const RegisteredService({ - required this.service, - required this.title, - }); + const RegisteredService({required this.service, required this.title}); final String service; final String title;
diff --git a/packages/devtools_shared/lib/src/test/chrome.dart b/packages/devtools_shared/lib/src/test/chrome.dart index ddc275b..294385b 100644 --- a/packages/devtools_shared/lib/src/test/chrome.dart +++ b/packages/devtools_shared/lib/src/test/chrome.dart
@@ -16,7 +16,8 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' hide ChromeTab; import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' - as wip show ChromeTab; + as wip + show ChromeTab; import 'io_utils.dart'; @@ -94,10 +95,7 @@ '--remote-debugging-port=$debugPort', ]; if (useChromeHeadless && headlessModeIsSupported) { - args.addAll(<String>[ - '--headless', - '--disable-gpu', - ]); + args.addAll(<String>['--headless', '--disable-gpu']); } if (url != null) { args.add(url); @@ -153,12 +151,9 @@ required bool Function(wip.ChromeTab) tabFound, required Duration timeout, }) async { - final wipTab = await connection.getTab( - (wip.ChromeTab tab) { - return tabFound(tab); - }, - retryFor: timeout, - ); + final wipTab = await connection.getTab((wip.ChromeTab tab) { + return tabFound(tab); + }, retryFor: timeout); unawaited( process.exitCode.then((_) { @@ -214,8 +209,9 @@ }); unawaited( - _exceptionThrownController - .addStream(wipConnection.runtime.onExceptionThrown), + _exceptionThrownController.addStream( + wipConnection.runtime.onExceptionThrown, + ), ); unawaited(wipConnection.page.enable());
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 5808cf4..1530e80 100644 --- a/packages/devtools_shared/lib/src/test/cli_test_driver.dart +++ b/packages/devtools_shared/lib/src/test/cli_test_driver.dart
@@ -28,8 +28,9 @@ _onAppStarted = lines.first; unawaited(serviceConnection.streamListen(EventStreams.kIsolate)); - _isolateEventStreamSubscription = - serviceConnection.onIsolateEvent.listen((Event event) { + _isolateEventStreamSubscription = serviceConnection.onIsolateEvent.listen(( + Event event, + ) { if (event.kind == EventKind.kIsolateExit) { isolates.remove(event.isolate); } else { @@ -86,27 +87,30 @@ List<IsolateRef> isolates, Future<void> Function()? onTeardown, ) : super._( - process, - lines, - serviceUri, - serviceConnection, - isolates, - onTeardown, - ); + process, + lines, + serviceUri, + serviceConnection, + isolates, + onTeardown, + ); final String appScriptPath; static Future<CliAppFixture> create(String appScriptPath) async { - final dartVmServicePrefix = - RegExp('(Observatory|The Dart VM service is) listening on '); - - final process = await Process.start( - Platform.resolvedExecutable, - <String>['--observe=0', '--pause-isolates-on-start', appScriptPath], + final dartVmServicePrefix = RegExp( + '(Observatory|The Dart VM service is) listening on ', ); - final Stream<String> lines = - process.stdout.transform(utf8.decoder).transform(const LineSplitter()); + final process = await Process.start(Platform.resolvedExecutable, <String>[ + '--observe=0', + '--pause-isolates-on-start', + appScriptPath, + ]); + + final Stream<String> lines = process.stdout + .transform(utf8.decoder) + .transform(const LineSplitter()); final lineController = StreamController<String>.broadcast(); final completer = Completer<String>(); @@ -166,16 +170,18 @@ const skipId = 'skip'; final vm = await serviceConnection.getVM(); 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<Isolate>.value(Isolate(id: skipId)); - })) + .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<Isolate>.value(Isolate(id: skipId)); + }), + ) .wait; foundIsolate = isolates.firstWhereOrNull( (isolate) =>
diff --git a/packages/devtools_shared/lib/src/test/integration_test_runner.dart b/packages/devtools_shared/lib/src/test/integration_test_runner.dart index 54e0f8b..0733851 100644 --- a/packages/devtools_shared/lib/src/test/integration_test_runner.dart +++ b/packages/devtools_shared/lib/src/test/integration_test_runner.dart
@@ -67,7 +67,9 @@ debugLog('> flutter ${flutterDriveArgs.join(' ')}'); final process = await Process.start( - Platform.isWindows ? 'flutter.bat' : 'flutter', flutterDriveArgs); + Platform.isWindows ? 'flutter.bat' : 'flutter', + flutterDriveArgs, + ); bool stdOutWriteInProgress = false; bool stdErrWriteInProgress = false; @@ -119,12 +121,15 @@ ); bool testTimedOut = false; - await process.exitCode.timeout(const Duration(minutes: 8), onTimeout: () { - testTimedOut = true; - // TODO(srawlins): Refactor the retry situation to catch a - // TimeoutException, and not recursively call `runTest`. - return -1; - }); + await process.exitCode.timeout( + const Duration(minutes: 8), + onTimeout: () { + testTimedOut = true; + // TODO(srawlins): Refactor the retry situation to catch a + // TimeoutException, and not recursively call `runTest`. + return -1; + }, + ); debugLog( 'shutting down processes because ' @@ -172,7 +177,7 @@ final result = json[resultKey] == 'true'; final failureDetails = (json[failureDetailsKey] as List<Object?>).cast<String>().firstOrNull ?? - '{}'; + '{}'; final failureDetailsMap = jsonDecode(failureDetails) as Map<String, Object?>; final methodName = failureDetailsMap[methodNameKey] as String?; @@ -204,8 +209,8 @@ List<String> args, { bool verifyValidTarget = true, void Function(ArgParser)? addExtraArgs, - }) : rawArgs = args, - argResults = buildArgParser(addExtraArgs: addExtraArgs).parse(args) { + }) : rawArgs = args, + argResults = buildArgParser(addExtraArgs: addExtraArgs).parse(args) { if (verifyValidTarget) { final target = argResults[testTargetArg]; assert( @@ -261,15 +266,9 @@ static const _shardArg = 'shard'; /// Builds an arg parser for DevTools integration tests. - static ArgParser buildArgParser({ - void Function(ArgParser)? addExtraArgs, - }) { + static ArgParser buildArgParser({void Function(ArgParser)? addExtraArgs}) { final argParser = ArgParser() - ..addFlag( - _helpArg, - abbr: 'h', - help: 'Prints help output.', - ) + ..addFlag(_helpArg, abbr: 'h', help: 'Prints help output.') ..addOption( testTargetArg, abbr: 't', @@ -293,7 +292,8 @@ ..addOption( _shardArg, valueHelp: '1/3', - help: 'The shard number for this run out of the total number of shards ' + help: + 'The shard number for this run out of the total number of shards ' '(e.g. 1/3)', ); addExtraArgs?.call(argParser);
diff --git a/packages/devtools_shared/lib/src/test/io_utils.dart b/packages/devtools_shared/lib/src/test/io_utils.dart index eb1b5c8..3c6e60b 100644 --- a/packages/devtools_shared/lib/src/test/io_utils.dart +++ b/packages/devtools_shared/lib/src/test/io_utils.dart
@@ -65,10 +65,7 @@ Future<void> cancelAllStreamSubscriptions() async { await streamSubscriptions.map((s) => s.cancel()).wait; - await [ - stdoutController.close(), - stderrController.close(), - ].wait; + await [stdoutController.close(), stderrController.close()].wait; streamSubscriptions.clear(); } @@ -98,10 +95,7 @@ ); } - Future<int> killForcefully( - Process process, { - bool debugLogging = false, - }) { + Future<int> killForcefully(Process process, {bool debugLogging = false}) { final processId = process.pid; // Use sigint here instead of sigkill. See // https://github.com/flutter/flutter/issues/117415.
diff --git a/packages/devtools_shared/lib/src/utils/file_utils.dart b/packages/devtools_shared/lib/src/utils/file_utils.dart index 553e6e6..3822720 100644 --- a/packages/devtools_shared/lib/src/utils/file_utils.dart +++ b/packages/devtools_shared/lib/src/utils/file_utils.dart
@@ -78,8 +78,9 @@ // If we do not have access to DTD or if we failed to detect the package root // by walking the directory structure, default to using a regexp heuristic. - final directoryRegExp = - RegExp(r'\/(lib|bin|integration_test|test|benchmark|example)\/.+\.dart'); + final directoryRegExp = RegExp( + r'\/(lib|bin|integration_test|test|benchmark|example)\/.+\.dart', + ); final directoryIndex = fileUriString.lastIndexOf(directoryRegExp); if (directoryIndex != -1) { fileUriString = fileUriString.substring(0, directoryIndex);
diff --git a/packages/devtools_shared/lib/src/utils/retry.dart b/packages/devtools_shared/lib/src/utils/retry.dart index 4925962..6ce76d4 100644 --- a/packages/devtools_shared/lib/src/utils/retry.dart +++ b/packages/devtools_shared/lib/src/utils/retry.dart
@@ -22,9 +22,11 @@ FutureOr<bool> Function()? stopCondition, FutureOr<void> Function(int attempt)? onRetry, }) async { - for (var attempt = 1; - attempt <= maxRetries && (await stopCondition?.call() != true); - attempt++) { + for ( + var attempt = 1; + attempt <= maxRetries && (await stopCondition?.call() != true); + attempt++ + ) { try { await callback(); break;
diff --git a/packages/devtools_shared/lib/src/utils/semantic_version.dart b/packages/devtools_shared/lib/src/utils/semantic_version.dart index 3e8046f..d4cfe22 100644 --- a/packages/devtools_shared/lib/src/utils/semantic_version.dart +++ b/packages/devtools_shared/lib/src/utils/semantic_version.dart
@@ -25,22 +25,26 @@ final semVersion = splitOnDash.first; final versionParts = semVersion.split('.'); - final major = - versionParts.isNotEmpty ? int.tryParse(versionParts.first) ?? 0 : 0; - final minor = - versionParts.length > 1 ? int.tryParse(versionParts[1]) ?? 0 : 0; - final patch = - versionParts.length > 2 ? int.tryParse(versionParts[2]) ?? 0 : 0; + final major = versionParts.isNotEmpty + ? int.tryParse(versionParts.first) ?? 0 + : 0; + final minor = versionParts.length > 1 + ? int.tryParse(versionParts[1]) ?? 0 + : 0; + final patch = versionParts.length > 2 + ? int.tryParse(versionParts[2]) ?? 0 + : 0; int? preReleaseMajor; int? preReleaseMinor; if (splitOnDash.length == 2) { final preRelease = splitOnDash.last; - final preReleaseParts = preRelease - .split('.') - .map((part) => RegExp(r'\d+').stringMatch(part) ?? '') - .toList() - ..removeWhere((part) => part.isEmpty); + final preReleaseParts = + preRelease + .split('.') + .map((part) => RegExp(r'\d+').stringMatch(part) ?? '') + .toList() + ..removeWhere((part) => part.isEmpty); preReleaseMajor = preReleaseParts.isNotEmpty ? int.tryParse(preReleaseParts.first) ?? 0 : 0; @@ -83,11 +87,7 @@ if (downgradePatch) { patch = math.max(0, patch - 1); } - return SemanticVersion( - major: major, - minor: minor, - patch: patch, - ); + return SemanticVersion(major: major, minor: minor, patch: patch); } int major; @@ -134,8 +134,10 @@ /// /// e.g. 2.6.0-12.0.pre-443 -> 2.6.0-12.0.pre.443 static String _canonicalizeVersion(String semanticVersion) => - semanticVersion.replaceFirstMapped(_nonStandardPreReleaseVersionRegex, - (match) => '${match[1]}.${match[2]}'); + semanticVersion.replaceFirstMapped( + _nonStandardPreReleaseVersionRegex, + (match) => '${match[1]}.${match[2]}', + ); bool get isPreRelease => preReleaseMajor != null || preReleaseMinor != null;
diff --git a/packages/devtools_shared/test/deeplink/deeplink_manager_test.dart b/packages/devtools_shared/test/deeplink/deeplink_manager_test.dart index e96d45b..fb36b12 100644 --- a/packages/devtools_shared/test/deeplink/deeplink_manager_test.dart +++ b/packages/devtools_shared/test/deeplink/deeplink_manager_test.dart
@@ -39,15 +39,10 @@ '--list-build-variants', projectRoot, ], - result: ProcessResult( - 0, - 0, - r''' + result: ProcessResult(0, 0, r''' Running Gradle task 'printBuildVariants'... 10.4s ["debug","release","profile"] - ''', - '', - ), + ''', ''), ), ); final response = await manager.getAndroidBuildVariants( @@ -60,42 +55,36 @@ ); }); - test('getBuildVariants propagates parent IDE and analytics opt-out status', - () async { - const projectRoot = '/abc'; - manager.expectedCommands.add( - TestCommand( - executable: manager.mockedFlutterBinary, - arguments: <String>[ - 'analyze', - '--android', - '--list-build-variants', - projectRoot, - ], - ide: 'VS-Code', - suppressAnalytics: true, - result: ProcessResult( - 0, - 0, - r''' + test( + 'getBuildVariants propagates parent IDE and analytics opt-out status', + () async { + const projectRoot = '/abc'; + manager.expectedCommands.add( + TestCommand( + executable: manager.mockedFlutterBinary, + arguments: <String>[ + 'analyze', + '--android', + '--list-build-variants', + projectRoot, + ], + ide: 'VS-Code', + suppressAnalytics: true, + result: ProcessResult(0, 0, r''' Running Gradle task 'printBuildVariants'... 10.4s ["debug"] - ''', - '', + ''', ''), ), - ), - ); - final response = await manager.getAndroidBuildVariants( - rootPath: projectRoot, - ide: 'VS-Code', - suppressAnalytics: true, - ); - expect(response[DeeplinkManager.kErrorField], isNull); - expect( - response[DeeplinkManager.kOutputJsonField], - '["debug"]', - ); - }); + ); + final response = await manager.getAndroidBuildVariants( + rootPath: projectRoot, + ide: 'VS-Code', + suppressAnalytics: true, + ); + expect(response[DeeplinkManager.kErrorField], isNull); + expect(response[DeeplinkManager.kOutputJsonField], '["debug"]'); + }, + ); test( 'getBuildVariants return internal server error if command failed', @@ -110,12 +99,7 @@ '--list-build-variants', projectRoot, ], - result: ProcessResult( - 0, - 1, - '', - 'unknown error', - ), + result: ProcessResult(0, 1, '', 'unknown error'), ), ); final response = await manager.getAndroidBuildVariants( @@ -144,15 +128,10 @@ '--build-variant=$buildVariant', projectRoot, ], - result: ProcessResult( - 0, - 0, - ''' + result: ProcessResult(0, 0, ''' Running Gradle task 'printBuildVariants'... 10.4s result saved in ${jsonFile.absolute.path} - ''', - '', - ), + ''', ''), ), ); final response = await manager.getAndroidAppLinkSettings( @@ -160,10 +139,7 @@ rootPath: projectRoot, ); expect(response[DeeplinkManager.kErrorField], isNull); - expect( - response[DeeplinkManager.kOutputJsonField], - json, - ); + expect(response[DeeplinkManager.kOutputJsonField], json); }); test( @@ -186,15 +162,10 @@ '--target=$target', projectRoot, ], - result: ProcessResult( - 0, - 0, - ''' + result: ProcessResult(0, 0, ''' Running Gradle task 'printBuildVariants'... 10.4s result saved in ${jsonFile.absolute.path} - ''', - '', - ), + ''', ''), ), ); final response = await manager.getIosUniversalLinkSettings( @@ -203,10 +174,7 @@ rootPath: projectRoot, ); expect(response[DeeplinkManager.kErrorField], isNull); - expect( - response[DeeplinkManager.kOutputJsonField], - json, - ); + expect(response[DeeplinkManager.kOutputJsonField], json); }, ); @@ -221,19 +189,12 @@ '--list-build-options', projectRoot, ], - result: ProcessResult( - 0, - 0, - r''' + result: ProcessResult(0, 0, r''' {"configurations":["Debug","Release","Profile"],"targets":["Runner","RunnerTests"]} - ''', - '', - ), + ''', ''), ), ); - final response = await manager.getIosBuildOptions( - rootPath: projectRoot, - ); + final response = await manager.getIosBuildOptions(rootPath: projectRoot); expect(response[DeeplinkManager.kErrorField], isNull); expect( response[DeeplinkManager.kOutputJsonField], @@ -261,8 +222,10 @@ final expectedCommand = expectedCommands.removeAt(0); expect(executable, expectedCommand.executable); expect( - const ListEquality<String>() - .equals(arguments, expectedCommand.arguments), + const ListEquality<String>().equals( + arguments, + expectedCommand.arguments, + ), isTrue, ); expect(ide, expectedCommand.ide);
diff --git a/packages/devtools_shared/test/extensions/extension_enablement_test.dart b/packages/devtools_shared/test/extensions/extension_enablement_test.dart index f0740e4..36984b3 100644 --- a/packages/devtools_shared/test/extensions/extension_enablement_test.dart +++ b/packages/devtools_shared/test/extensions/extension_enablement_test.dart
@@ -41,14 +41,11 @@ extensionName: 'foo', ); final file = optionsFileFromTmp(); - expect( - file.readAsStringSync(), - ''' + expect(file.readAsStringSync(), ''' description: This file stores settings for Dart & Flutter DevTools. documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states extensions: -''', - ); +'''); }); test('can write to options file', () { @@ -58,14 +55,11 @@ enable: true, ); final file = optionsFileFromTmp(); - expect( - file.readAsStringSync(), - ''' + expect(file.readAsStringSync(), ''' description: This file stores settings for Dart & Flutter DevTools. documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states extensions: - - foo: true''', - ); + - foo: true'''); }); test('can read from options file', () { @@ -80,15 +74,12 @@ enable: false, ); final file = optionsFileFromTmp(); - expect( - file.readAsStringSync(), - ''' + expect(file.readAsStringSync(), ''' description: This file stores settings for Dart & Flutter DevTools. documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states extensions: - foo: true - - bar: false''', - ); + - bar: false'''); expect( options.lookupExtensionEnabledState(
diff --git a/packages/devtools_shared/test/extensions/extension_model_test.dart b/packages/devtools_shared/test/extensions/extension_model_test.dart index 8380b16..2bf4236 100644 --- a/packages/devtools_shared/test/extensions/extension_model_test.dart +++ b/packages/devtools_shared/test/extensions/extension_model_test.dart
@@ -113,144 +113,120 @@ } test('name', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsMissingRequiredFieldsError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': + 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsMissingRequiredFieldsError()); }); test('issueTracker', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsMissingRequiredFieldsError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': + 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsMissingRequiredFieldsError()); }); test('version', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'issueTracker': 'www.google.com', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsMissingRequiredFieldsError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'issueTracker': 'www.google.com', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': + 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsMissingRequiredFieldsError()); }); test('materialIconCodePoint', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsMissingRequiredFieldsError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': + 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsMissingRequiredFieldsError()); }); test('extensionAssetsPath', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsMissingGeneratedKeysError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'devtoolsOptionsUri': + 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsMissingGeneratedKeysError()); }); test('devtoolsOptionsUri', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsMissingGeneratedKeysError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsMissingGeneratedKeysError()); }); test('isPubliclyHosted', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': 'path/to/package/devtools_options.yaml', - 'detectedFromStaticContext': 'false', - }); - }, - throwsMissingGeneratedKeysError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': 'path/to/package/devtools_options.yaml', + 'detectedFromStaticContext': 'false', + }); + }, throwsMissingGeneratedKeysError()); }); test('detectedFromStaticContext', () { - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - }); - }, - throwsMissingGeneratedKeysError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': + 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + }); + }, throwsMissingGeneratedKeysError()); }); }); @@ -265,41 +241,33 @@ ); } - expect( - () { - DevToolsExtensionConfig.parse({ - // Expects a String here. - 'name': 23, - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsUnexpectedValueTypesError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + // Expects a String here. + 'name': 23, + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsUnexpectedValueTypesError()); - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'foo', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - // Expects a String here. - 'isPubliclyHosted': false, - 'detectedFromStaticContext': 'false', - }); - }, - throwsUnexpectedValueTypesError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'foo', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': 'file:///path/to/package/devtools_options.yaml', + // Expects a String here. + 'isPubliclyHosted': false, + 'detectedFromStaticContext': 'false', + }); + }, throwsUnexpectedValueTypesError()); }); test('parse throws for invalid name', () { @@ -313,56 +281,44 @@ ); } - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'name with spaces', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsInvalidNameError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'name with spaces', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsInvalidNameError()); - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'Name_With_Capital_Letters', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsInvalidNameError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'Name_With_Capital_Letters', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsInvalidNameError()); - expect( - () { - DevToolsExtensionConfig.parse({ - 'name': 'name.with\'specialchars/', - 'issueTracker': 'www.google.com', - 'version': '1.0.0', - 'materialIconCodePoint': 0xf012, - 'extensionAssetsPath': '/absolute/path/to/foo/extension', - 'devtoolsOptionsUri': - 'file:///path/to/package/devtools_options.yaml', - 'isPubliclyHosted': 'false', - 'detectedFromStaticContext': 'false', - }); - }, - throwsInvalidNameError(), - ); + expect(() { + DevToolsExtensionConfig.parse({ + 'name': 'name.with\'specialchars/', + 'issueTracker': 'www.google.com', + 'version': '1.0.0', + 'materialIconCodePoint': 0xf012, + 'extensionAssetsPath': '/absolute/path/to/foo/extension', + 'devtoolsOptionsUri': 'file:///path/to/package/devtools_options.yaml', + 'isPubliclyHosted': 'false', + 'detectedFromStaticContext': 'false', + }); + }, throwsInvalidNameError()); }); }); }
diff --git a/packages/devtools_shared/test/helpers/extension_test_manager.dart b/packages/devtools_shared/test/helpers/extension_test_manager.dart index 0355e72..323ab81 100644 --- a/packages/devtools_shared/test/helpers/extension_test_manager.dart +++ b/packages/devtools_shared/test/helpers/extension_test_manager.dart
@@ -94,8 +94,9 @@ // Generate the .dart_tool/package_config.json file for each Dart package. final testDirectoryContents = testDirectory.listSync(); expect(testDirectoryContents.length, 2); - final packageRoots = - Directory.fromUri(packagesRootUri).listSync().whereType<Directory>(); + final packageRoots = Directory.fromUri( + packagesRootUri, + ).listSync().whereType<Directory>(); expect(packageRoots.length, 4); for (final packageRoot in packageRoots) { @@ -103,11 +104,10 @@ // Run `dart pub get` on this package to generate the // `.dart_tool/package_config.json` file. - final process = await Process.run( - Platform.resolvedExecutable, - ['pub', 'get'], - workingDirectory: packageRoot.path, - ); + final process = await Process.run(Platform.resolvedExecutable, [ + 'pub', + 'get', + ], workingDirectory: packageRoot.path); if (process.exitCode != 0) { throw Exception( 'Encountered error while running pub get. Exit code: ' @@ -174,13 +174,13 @@ void setupWorkspace(TestPackage package) { File( - p.join( - testDirectory.path, - 'packages', - 'workspace_root', - 'pubspec.yaml', - ), - ) + p.join( + testDirectory.path, + 'packages', + 'workspace_root', + 'pubspec.yaml', + ), + ) ..createSync(recursive: true) ..writeAsStringSync(''' name: _ @@ -190,14 +190,14 @@ - ${package.name} '''); File( - p.join( - testDirectory.path, - 'packages', - 'workspace_root', - package.name, - 'pubspec.yaml', - ), - ) + p.join( + testDirectory.path, + 'packages', + 'workspace_root', + package.name, + 'pubspec.yaml', + ), + ) ..createSync(recursive: true) ..writeAsStringSync(''' ${package.pubspecContent} @@ -244,12 +244,13 @@ ..createSync(recursive: true); _packagesRootUri = Uri.file(packagesDirectory.uri.toFilePath()); - final projectRootDirectory = - Directory(p.join(packagesDirectory.path, package.name)) - ..createSync(recursive: true); + final projectRootDirectory = Directory( + p.join(packagesDirectory.path, package.name), + )..createSync(recursive: true); if (isRuntimeRoot) { - final directoryPath = - Uri.file(projectRootDirectory.uri.toFilePath()).toString(); + final directoryPath = Uri.file( + projectRootDirectory.uri.toFilePath(), + ).toString(); // Remove the trailing slash and set the value of [packagesRoot]. _runtimeAppRoot = directoryPath.substring(0, directoryPath.length - 1); } @@ -267,9 +268,9 @@ package.relativePathFromExtensions, ), )..createSync(recursive: true); - final extensionDir = - Directory(p.join(extensionDirectory.path, 'extension', 'devtools')) - ..createSync(recursive: true); + final extensionDir = Directory( + p.join(extensionDirectory.path, 'extension', 'devtools'), + )..createSync(recursive: true); Directory(p.join(extensionDir.path, 'build')).createSync(recursive: true); File(p.join(extensionDir.path, 'config.yaml')) @@ -288,8 +289,9 @@ }) { return TestPackage( name: originalPackage.name, - dependencies: - includeDependenciesWithExtensions ? originalPackage.dependencies : [], + dependencies: includeDependenciesWithExtensions + ? originalPackage.dependencies + : [], pathToExtensions: originalPackage.pathToExtensions, ); } @@ -383,9 +385,9 @@ required this.isPubliclyHosted, required this.packageVersion, String? relativePathFromExtensions, - }) : assert(isPubliclyHosted == (packageVersion != null)), - relativePathFromExtensions = - relativePathFromExtensions ?? name.toLowerCase(); + }) : assert(isPubliclyHosted == (packageVersion != null)), + relativePathFromExtensions = + relativePathFromExtensions ?? name.toLowerCase(); final String name; final String issueTracker; @@ -400,7 +402,8 @@ /// Uses the paths separator for the current platform. final String relativePathFromExtensions; - String get configYamlContent => ''' + String get configYamlContent => + ''' name: $name issueTracker: $issueTracker version: $version @@ -408,7 +411,8 @@ ${!requiresConnection ? 'requiresConnection: false' : ''} '''; - String get pubspecContent => ''' + String get pubspecContent => + ''' name: ${name.toLowerCase()} environment: sdk: ">=3.4.0-282.1.beta <4.0.0" @@ -426,7 +430,8 @@ final List<TestPackageWithExtension> dependencies; final String pathToExtensions; - String get pubspecContent => ''' + String get pubspecContent => + ''' name: $name environment: sdk: "^3.5.0"
diff --git a/packages/devtools_shared/test/helpers/extension_test_manager_test.dart b/packages/devtools_shared/test/helpers/extension_test_manager_test.dart index 9bf976d..e810145 100644 --- a/packages/devtools_shared/test/helpers/extension_test_manager_test.dart +++ b/packages/devtools_shared/test/helpers/extension_test_manager_test.dart
@@ -51,24 +51,18 @@ staticExtension1Package.relativePathFromExtensions, staticExtension1Package.name, ); - expect( - staticExtension1Package.pubspecContent, - ''' + expect(staticExtension1Package.pubspecContent, ''' name: static_extension_1 environment: sdk: ">=3.4.0-282.1.beta <4.0.0" -''', - ); - expect( - staticExtension1Package.configYamlContent, - ''' +'''); + expect(staticExtension1Package.configYamlContent, ''' name: static_extension_1 issueTracker: https://www.google.com/ version: 1.0.0 materialIconCodePoint: 58634 requiresConnection: false -''', - ); +'''); }); test('$staticExtension2Package', () { @@ -83,24 +77,18 @@ staticExtension2Package.relativePathFromExtensions, staticExtension2Package.name, ); - expect( - staticExtension2Package.pubspecContent, - ''' + expect(staticExtension2Package.pubspecContent, ''' name: static_extension_2 environment: sdk: ">=3.4.0-282.1.beta <4.0.0" -''', - ); - expect( - staticExtension2Package.configYamlContent, - ''' +'''); + expect(staticExtension2Package.configYamlContent, ''' name: static_extension_2 issueTracker: https://www.google.com/ version: 2.0.0 materialIconCodePoint: 58634 requiresConnection: false -''', - ); +'''); }); test('$newerStaticExtension1Package', () { @@ -118,24 +106,18 @@ newerStaticExtension1Package.relativePathFromExtensions, p.join('newer', 'static_extension_1'), ); - expect( - newerStaticExtension1Package.pubspecContent, - ''' + expect(newerStaticExtension1Package.pubspecContent, ''' name: static_extension_1 environment: sdk: ">=3.4.0-282.1.beta <4.0.0" -''', - ); - expect( - newerStaticExtension1Package.configYamlContent, - ''' +'''); + expect(newerStaticExtension1Package.configYamlContent, ''' name: static_extension_1 issueTracker: https://www.google.com/ version: 2.0.0 materialIconCodePoint: 58634 requiresConnection: false -''', - ); +'''); }); test('$badExtensionPackage', () { @@ -150,24 +132,18 @@ badExtensionPackage.relativePathFromExtensions, badExtensionPackage.name.toLowerCase(), ); - expect( - badExtensionPackage.pubspecContent, - ''' + expect(badExtensionPackage.pubspecContent, ''' name: bad_extension environment: sdk: ">=3.4.0-282.1.beta <4.0.0" -''', - ); - expect( - badExtensionPackage.configYamlContent, - ''' +'''); + expect(badExtensionPackage.configYamlContent, ''' name: BAD_EXTENSION issueTracker: https://www.google.com/ version: 1.0.0 materialIconCodePoint: 58634 -''', - ); +'''); }); }); @@ -175,9 +151,7 @@ test('$myAppPackage', () { expect(myAppPackage.name, 'my_app'); expect(myAppPackage.dependencies.length, 3); - expect( - myAppPackage.pubspecContent, - ''' + expect(myAppPackage.pubspecContent, ''' name: my_app environment: sdk: "^3.5.0" @@ -187,16 +161,13 @@ static_extension_1: path: ../../extensions/static_extension_1 -''', - ); +'''); }); test('$myAppPackageWithBadExtension', () { expect(myAppPackageWithBadExtension.name, 'my_app'); expect(myAppPackageWithBadExtension.dependencies.length, 4); - expect( - myAppPackageWithBadExtension.pubspecContent, - ''' + expect(myAppPackageWithBadExtension.pubspecContent, ''' name: my_app environment: sdk: "^3.5.0" @@ -208,16 +179,13 @@ bad_extension: path: ../../extensions/bad_extension -''', - ); +'''); }); test('$otherRoot1Package', () { expect(otherRoot1Package.name, 'other_root_1'); expect(otherRoot1Package.dependencies.length, 2); - expect( - otherRoot1Package.pubspecContent, - ''' + expect(otherRoot1Package.pubspecContent, ''' name: other_root_1 environment: sdk: "^3.5.0" @@ -227,16 +195,13 @@ static_extension_2: path: ../../extensions/static_extension_2 -''', - ); +'''); }); test('$otherRoot2Package', () { expect(otherRoot2Package.name, 'other_root_2'); expect(otherRoot2Package.dependencies.length, 1); - expect( - otherRoot2Package.pubspecContent, - ''' + expect(otherRoot2Package.pubspecContent, ''' name: other_root_2 environment: sdk: "^3.5.0" @@ -244,8 +209,7 @@ static_extension_1: path: ../../extensions/newer/static_extension_1 -''', - ); +'''); }); test('createTestPackageFrom when excluding dependencies', () { @@ -253,58 +217,46 @@ myAppPackage, includeDependenciesWithExtensions: false, ); - expect( - pkg.pubspecContent, - ''' + expect(pkg.pubspecContent, ''' name: my_app environment: sdk: "^3.5.0" dependencies: -''', - ); +'''); pkg = createTestPackageFrom( myAppPackageWithBadExtension, includeDependenciesWithExtensions: false, ); - expect( - pkg.pubspecContent, - ''' + expect(pkg.pubspecContent, ''' name: my_app environment: sdk: "^3.5.0" dependencies: -''', - ); +'''); pkg = createTestPackageFrom( otherRoot1Package, includeDependenciesWithExtensions: false, ); - expect( - pkg.pubspecContent, - ''' + expect(pkg.pubspecContent, ''' name: other_root_1 environment: sdk: "^3.5.0" dependencies: -''', - ); +'''); pkg = createTestPackageFrom( otherRoot2Package, includeDependenciesWithExtensions: false, ); - expect( - pkg.pubspecContent, - ''' + expect(pkg.pubspecContent, ''' name: other_root_2 environment: sdk: "^3.5.0" dependencies: -''', - ); +'''); }); }); }
diff --git a/packages/devtools_shared/test/helpers/helpers.dart b/packages/devtools_shared/test/helpers/helpers.dart index 523795b..3f174aa 100644 --- a/packages/devtools_shared/test/helpers/helpers.dart +++ b/packages/devtools_shared/test/helpers/helpers.dart
@@ -9,10 +9,7 @@ import 'package:devtools_shared/devtools_shared.dart'; import 'package:path/path.dart' as path; -typedef TestDtdConnectionInfo = ({ - DtdInfo? info, - Process? process, -}); +typedef TestDtdConnectionInfo = ({DtdInfo? info, Process? process}); /// Helper method to start DTD for the purpose of testing. Future<TestDtdConnectionInfo> startDtd() async { @@ -25,28 +22,25 @@ TestDtdConnectionInfo onFailure() => (info: null, process: dtdProcess); try { - dtdProcess = await Process.start( - Platform.resolvedExecutable, - ['tooling-daemon', '--machine'], - ); + dtdProcess = await Process.start(Platform.resolvedExecutable, [ + 'tooling-daemon', + '--machine', + ]); dtdStoutSubscription = dtdProcess.stdout.listen((List<int> data) { try { final decoded = utf8.decode(data); final json = jsonDecode(decoded) as Map<String, Object?>; - if (json - case { - 'tooling_daemon_details': { - 'uri': final String uri, - 'trusted_client_secret': final String secret, - } - }) { - completer.complete( - ( - info: DtdInfo(Uri.parse(uri), secret: secret), - process: dtdProcess, - ), - ); + if (json case { + 'tooling_daemon_details': { + 'uri': final String uri, + 'trusted_client_secret': final String secret, + }, + }) { + completer.complete(( + info: DtdInfo(Uri.parse(uri), secret: secret), + process: dtdProcess, + )); } else { completer.complete(onFailure()); } @@ -58,9 +52,9 @@ return await completer.future .timeout(dtdConnectTimeout, onTimeout: onFailure) .then((value) async { - await dtdStoutSubscription?.cancel(); - return value; - }); + await dtdStoutSubscription?.cancel(); + return value; + }); } catch (e) { await dtdStoutSubscription?.cancel(); return onFailure(); @@ -78,11 +72,11 @@ Future<String> start() async { await _initTestApp(); - process = await Process.start( - Platform.resolvedExecutable, - ['--observe=0', 'run', 'bin/main.dart'], - workingDirectory: directory.path, - ); + process = await Process.start(Platform.resolvedExecutable, [ + '--observe=0', + 'run', + 'bin/main.dart', + ], workingDirectory: directory.path); final serviceUriCompleter = Completer<String>(); late StreamSubscription sub; @@ -90,13 +84,13 @@ .transform(utf8.decoder) .transform(const LineSplitter()) .listen((line) async { - if (line.contains(dartVMServiceRegExp)) { - await sub.cancel(); - serviceUriCompleter.complete( - dartVMServiceRegExp.firstMatch(line)!.group(1), - ); - } - }); + if (line.contains(dartVMServiceRegExp)) { + await sub.cancel(); + serviceUriCompleter.complete( + dartVMServiceRegExp.firstMatch(line)!.group(1), + ); + } + }); return await serviceUriCompleter.future.timeout( const Duration(seconds: 5), onTimeout: () async {
diff --git a/packages/devtools_shared/test/semantic_version_test.dart b/packages/devtools_shared/test/semantic_version_test.dart index 8e22b57..06b637b 100644 --- a/packages/devtools_shared/test/semantic_version_test.dart +++ b/packages/devtools_shared/test/semantic_version_test.dart
@@ -44,16 +44,10 @@ preReleaseMajor: 1, preReleaseMinor: 2, ); - expect( - version.downgrade().toString(), - equals('3.2.1'), - ); + expect(version.downgrade().toString(), equals('3.2.1')); version = SemanticVersion(major: 3, minor: 2, patch: 1); - expect( - version.downgrade().toString(), - equals('3.2.1'), - ); + expect(version.downgrade().toString(), equals('3.2.1')); expect( version.downgrade(downgradeMajor: true).toString(), equals('2.2.1'), @@ -87,18 +81,27 @@ isTrue, ); expect( - SemanticVersion(major: 1, minor: 1, patch: 2) - .isSupported(minSupportedVersion: supportedVersion), + SemanticVersion( + major: 1, + minor: 1, + patch: 2, + ).isSupported(minSupportedVersion: supportedVersion), isTrue, ); expect( - SemanticVersion(major: 1, minor: 2, patch: 1) - .isSupported(minSupportedVersion: supportedVersion), + SemanticVersion( + major: 1, + minor: 2, + patch: 1, + ).isSupported(minSupportedVersion: supportedVersion), isTrue, ); expect( - SemanticVersion(major: 2, minor: 1, patch: 1) - .isSupported(minSupportedVersion: supportedVersion), + SemanticVersion( + major: 2, + minor: 1, + patch: 1, + ).isSupported(minSupportedVersion: supportedVersion), isTrue, ); expect( @@ -123,10 +126,7 @@ version.compareTo(SemanticVersion(major: 2, minor: 1, patch: 1)), equals(-1), ); - expect( - version.compareTo(SemanticVersion(major: 1, minor: 1)), - equals(1), - ); + expect(version.compareTo(SemanticVersion(major: 1, minor: 1)), equals(1)); expect( version.compareTo(SemanticVersion(major: 1, minor: 1, patch: 1)), equals(0), @@ -184,8 +184,12 @@ equals('1.1.1'), ); expect( - SemanticVersion(major: 1, minor: 1, patch: 1, preReleaseMajor: 17) - .toString(), + SemanticVersion( + major: 1, + minor: 1, + patch: 1, + preReleaseMajor: 17, + ).toString(), equals('1.1.1-17'), ); expect(
diff --git a/packages/devtools_shared/test/server/devtools_extensions_api_test.dart b/packages/devtools_shared/test/server/devtools_extensions_api_test.dart index f075b47..185b7ff 100644 --- a/packages/devtools_shared/test/server/devtools_extensions_api_test.dart +++ b/packages/devtools_shared/test/server/devtools_extensions_api_test.dart
@@ -49,10 +49,9 @@ includeDependenciesWithExtensions: includeDependenciesWithExtensions, includeBadExtension: includeBadExtension, ); - await testDtdConnection!.setIDEWorkspaceRoots( - dtd!.info!.secret!, - [extensionTestManager.packagesRootUri], - ); + await testDtdConnection!.setIDEWorkspaceRoots(dtd!.info!.secret!, [ + extensionTestManager.packagesRootUri, + ]); } Future<Response> serveExtensions( @@ -66,8 +65,9 @@ host: 'localhost', path: ExtensionsApi.apiServeAvailableExtensions, queryParameters: { - ExtensionsApi.packageRootUriPropertyName: - includeRuntimeRoot ? extensionTestManager.runtimeAppRoot : null, + ExtensionsApi.packageRootUriPropertyName: includeRuntimeRoot + ? extensionTestManager.runtimeAppRoot + : null, }, ), ); @@ -128,9 +128,7 @@ test( 'fails when an exception is thrown and there are no valid extensions', () async { - await initializeTestDirectory( - includeDependenciesWithExtensions: false, - ); + await initializeTestDirectory(includeDependenciesWithExtensions: false); extensionsManager = _TestExtensionsManager(); final response = await serveExtensions(extensionsManager); expect(response.statusCode, HttpStatus.internalServerError); @@ -202,16 +200,16 @@ ExtensionEnabledState.none.name, ); -// TODO(kenz): why is existsSync() returning false when I can verify the file -// contents on the file system at [optionsFileUriString]? -// expect(optionsFile.existsSync(), isTrue); -// expect( -// optionsFile.readAsStringSync(), -// ''' -// description: This file stores settings for Dart & Flutter DevTools. -// documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states -// extensions:''', -// ); + // TODO(kenz): why is existsSync() returning false when I can verify the file + // contents on the file system at [optionsFileUriString]? + // expect(optionsFile.existsSync(), isTrue); + // expect( + // optionsFile.readAsStringSync(), + // ''' + // description: This file stores settings for Dart & Flutter DevTools. + // documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states + // extensions:''', + // ); response = await sendEnabledStateRequest( extensionName: 'drift', @@ -233,16 +231,16 @@ ExtensionEnabledState.disabled.name, ); -// expect(optionsFile.existsSync(), isTrue); -// expect( -// optionsFile.readAsStringSync(), -// ''' -// description: This file stores settings for Dart & Flutter DevTools. -// documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states -// extensions: -// - drift: true -// - provider: false''', -// ); + // expect(optionsFile.existsSync(), isTrue); + // expect( + // optionsFile.readAsStringSync(), + // ''' + // description: This file stores settings for Dart & Flutter DevTools. + // documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states + // extensions: + // - drift: true + // - provider: false''', + // ); }); }); }
diff --git a/packages/devtools_shared/test/server/dtd_api_test.dart b/packages/devtools_shared/test/server/dtd_api_test.dart index c54ae54..e6dd18d 100644 --- a/packages/devtools_shared/test/server/dtd_api_test.dart +++ b/packages/devtools_shared/test/server/dtd_api_test.dart
@@ -19,11 +19,7 @@ final dtdUri = Uri.parse('ws://dtd/uri'); final request = Request( 'get', - Uri( - scheme: 'https', - host: 'localhost', - path: DtdApi.apiGetDtdUri, - ), + Uri(scheme: 'https', host: 'localhost', path: DtdApi.apiGetDtdUri), ); final response = await ServerApi.handle( request,
diff --git a/packages/devtools_shared/test/server/general_api_test.dart b/packages/devtools_shared/test/server/general_api_test.dart index d931d53..c2bb000 100644 --- a/packages/devtools_shared/test/server/general_api_test.dart +++ b/packages/devtools_shared/test/server/general_api_test.dart
@@ -41,38 +41,32 @@ ); } - test( - 'succeeds when DTD is not available', - () async { - final response = await sendNotifyRequest( - dtd: null, - queryParameters: { - apiParameterValueKey: 'fake_uri', - apiParameterVmServiceConnected: 'true', - }, - ); - expect(response.statusCode, HttpStatus.ok); - expect(await response.readAsString(), isEmpty); - }, - ); + test('succeeds when DTD is not available', () async { + final response = await sendNotifyRequest( + dtd: null, + queryParameters: { + apiParameterValueKey: 'fake_uri', + apiParameterVmServiceConnected: 'true', + }, + ); + expect(response.statusCode, HttpStatus.ok); + expect(await response.readAsString(), isEmpty); + }); - test( - 'returns badRequest for invalid VM service argument', - () async { - final response = await sendNotifyRequest( - dtd: DtdInfo(Uri.parse('ws://dtd/uri'), secret: 'fake_secret'), - queryParameters: { - apiParameterValueKey: 'fake_uri', - apiParameterVmServiceConnected: 'true', - }, - ); - expect(response.statusCode, HttpStatus.badRequest); - expect( - await response.readAsString(), - contains('Cannot normalize VM service URI'), - ); - }, - ); + test('returns badRequest for invalid VM service argument', () async { + final response = await sendNotifyRequest( + dtd: DtdInfo(Uri.parse('ws://dtd/uri'), secret: 'fake_secret'), + queryParameters: { + apiParameterValueKey: 'fake_uri', + apiParameterVmServiceConnected: 'true', + }, + ); + expect(response.statusCode, HttpStatus.badRequest); + expect( + await response.readAsString(), + contains('Cannot normalize VM service URI'), + ); + }); test( 'returns badRequest for invalid $apiParameterVmServiceConnected argument', () async { @@ -99,8 +93,9 @@ setUp(() async { dtd = await startDtd(); expect(dtd!.info, isNotNull, reason: 'Error starting DTD for test'); - testDtdConnection = - await DartToolingDaemon.connect(dtd!.info!.localUri); + testDtdConnection = await DartToolingDaemon.connect( + dtd!.info!.localUri, + ); }); tearDown(() async { @@ -131,32 +126,28 @@ expect(currentRoots, containsAll(roots)); } - test( - 'adds and removes workspace roots', - () async { - await verifyWorkspaceRoots({}); - final rootUri1 = Uri.parse('file:///Users/me/package_root_1'); - final rootUri2 = Uri.parse('file:///Users/me/package_root_2'); + test('adds and removes workspace roots', () async { + await verifyWorkspaceRoots({}); + final rootUri1 = Uri.parse('file:///Users/me/package_root_1'); + final rootUri2 = Uri.parse('file:///Users/me/package_root_2'); - await updateWorkspaceRoots(root: rootUri1, connected: true); - await verifyWorkspaceRoots({rootUri1}); + await updateWorkspaceRoots(root: rootUri1, connected: true); + await verifyWorkspaceRoots({rootUri1}); - // Add a second root and verify the roots are unioned. - await updateWorkspaceRoots(root: rootUri2, connected: true); - await verifyWorkspaceRoots({rootUri1, rootUri2}); + // Add a second root and verify the roots are unioned. + await updateWorkspaceRoots(root: rootUri2, connected: true); + await verifyWorkspaceRoots({rootUri1, rootUri2}); - // Verify duplicates cannot be added. - await updateWorkspaceRoots(root: rootUri2, connected: true); - await verifyWorkspaceRoots({rootUri1, rootUri2}); + // Verify duplicates cannot be added. + await updateWorkspaceRoots(root: rootUri2, connected: true); + await verifyWorkspaceRoots({rootUri1, rootUri2}); - // Verify roots are removed for disconnect events. - await updateWorkspaceRoots(root: rootUri2, connected: false); - await verifyWorkspaceRoots({rootUri1}); - await updateWorkspaceRoots(root: rootUri1, connected: false); - await verifyWorkspaceRoots({}); - }, - timeout: const Timeout.factor(4), - ); + // Verify roots are removed for disconnect events. + await updateWorkspaceRoots(root: rootUri2, connected: false); + await verifyWorkspaceRoots({rootUri1}); + await updateWorkspaceRoots(root: rootUri1, connected: false); + await verifyWorkspaceRoots({}); + }, timeout: const Timeout.factor(4)); }); group('detectRootPackageForVmService', () { @@ -182,11 +173,11 @@ expect(vmServiceUri, isNotNull); final response = await server.VmServiceHandler.detectRootPackageForVmService( - vmServiceUriAsString: vmServiceUriString!, - vmServiceUri: vmServiceUri!, - connected: true, - dtd: testDtdConnection!, - ); + vmServiceUriAsString: vmServiceUriString!, + vmServiceUri: vmServiceUri!, + connected: true, + dtd: testDtdConnection!, + ); expect(response.success, true); expect(response.message, isNull); expect(response.uri, isNotNull); @@ -196,11 +187,11 @@ test('succeeds for a disconnect event when cache is empty', () async { final response = await server.VmServiceHandler.detectRootPackageForVmService( - vmServiceUriAsString: vmServiceUriString!, - vmServiceUri: Uri.parse('ws://127.0.0.1:63555/fake-uri=/ws'), - connected: false, - dtd: testDtdConnection!, - ); + vmServiceUriAsString: vmServiceUriString!, + vmServiceUri: Uri.parse('ws://127.0.0.1:63555/fake-uri=/ws'), + connected: false, + dtd: testDtdConnection!, + ); expect(response, (success: true, message: null, uri: null)); }); @@ -211,11 +202,11 @@ expect(vmServiceUri, isNotNull); final response = await server.VmServiceHandler.detectRootPackageForVmService( - vmServiceUriAsString: vmServiceUriString!, - vmServiceUri: vmServiceUri!, - connected: true, - dtd: testDtdConnection!, - ); + vmServiceUriAsString: vmServiceUriString!, + vmServiceUri: vmServiceUri!, + connected: true, + dtd: testDtdConnection!, + ); expect(response.success, true); expect(response.message, isNull); expect(response.uri, isNotNull); @@ -223,11 +214,11 @@ final disconnectResponse = await server.VmServiceHandler.detectRootPackageForVmService( - vmServiceUriAsString: vmServiceUriString!, - vmServiceUri: vmServiceUri, - connected: false, - dtd: testDtdConnection!, - ); + vmServiceUriAsString: vmServiceUriString!, + vmServiceUri: vmServiceUri, + connected: false, + dtd: testDtdConnection!, + ); expect(disconnectResponse.success, true); expect(disconnectResponse.message, isNull); expect(disconnectResponse.uri, isNotNull);
diff --git a/packages/devtools_shared/test/server/persistent_properties_test.dart b/packages/devtools_shared/test/server/persistent_properties_test.dart index 8358e7a..4f78b19 100644 --- a/packages/devtools_shared/test/server/persistent_properties_test.dart +++ b/packages/devtools_shared/test/server/persistent_properties_test.dart
@@ -15,8 +15,9 @@ const storeName = 'test_store'; setUp(() { - tempDir = - Directory.systemTemp.createTempSync('persistent_properties_test'); + tempDir = Directory.systemTemp.createTempSync( + 'persistent_properties_test', + ); properties = IOPersistentProperties( storeName, documentDirPath: tempDir.path,
diff --git a/packages/devtools_shared/test/service_utils_test.dart b/packages/devtools_shared/test/service_utils_test.dart index fe3a8df..351a6fb 100644 --- a/packages/devtools_shared/test/service_utils_test.dart +++ b/packages/devtools_shared/test/service_utils_test.dart
@@ -13,8 +13,9 @@ equals('http://127.0.0.1:60667/72K34Xmq0X0='), ); expect( - normalizeVmServiceUri('http://127.0.0.1:60667/72K34Xmq0X0=/ ') - .toString(), + normalizeVmServiceUri( + 'http://127.0.0.1:60667/72K34Xmq0X0=/ ', + ).toString(), equals('http://127.0.0.1:60667/72K34Xmq0X0=/'), ); expect( @@ -29,21 +30,24 @@ test('properly strips leading whitespace and trailing URI fragments', () { expect( - normalizeVmServiceUri(' http://127.0.0.1:60667/72K34Xmq0X0=/#/vm') - .toString(), + normalizeVmServiceUri( + ' http://127.0.0.1:60667/72K34Xmq0X0=/#/vm', + ).toString(), equals('http://127.0.0.1:60667/72K34Xmq0X0=/'), ); expect( - normalizeVmServiceUri(' http://127.0.0.1:60667/72K34Xmq0X0=/#/vm ') - .toString(), + normalizeVmServiceUri( + ' http://127.0.0.1:60667/72K34Xmq0X0=/#/vm ', + ).toString(), equals('http://127.0.0.1:60667/72K34Xmq0X0=/'), ); }); test('properly handles encoded urls', () { expect( - normalizeVmServiceUri('http%3A%2F%2F127.0.0.1%3A58824%2FCnvgRrQJG7w%3D') - .toString(), + normalizeVmServiceUri( + 'http%3A%2F%2F127.0.0.1%3A58824%2FCnvgRrQJG7w%3D', + ).toString(), equals('http://127.0.0.1:58824/CnvgRrQJG7w='), );
diff --git a/packages/devtools_shared/test/utils/file_utils_test.dart b/packages/devtools_shared/test/utils/file_utils_test.dart index fd75504..03b6c9a 100644 --- a/packages/devtools_shared/test/utils/file_utils_test.dart +++ b/packages/devtools_shared/test/utils/file_utils_test.dart
@@ -46,10 +46,9 @@ _setupTestDirectoryStructure(); - await testDtdConnection!.setIDEWorkspaceRoots( - dtd!.info!.secret!, - [Uri.parse(projectRootUriString)], - ); + await testDtdConnection!.setIDEWorkspaceRoots(dtd!.info!.secret!, [ + Uri.parse(projectRootUriString), + ]); }); tearDown(() async { @@ -78,12 +77,9 @@ } test('packageRootFromFileUriString throw exception for invalid input', () { - expect( - () async { - await packageRootFromFileUriString('/not/a/valid/file/uri'); - }, - throwsA(isA<AssertionError>()), - ); + expect(() async { + await packageRootFromFileUriString('/not/a/valid/file/uri'); + }, throwsA(isA<AssertionError>())); }); for (final useDtd in const [true, false]) { @@ -113,10 +109,7 @@ ); // Dart file under 'benchmark' - await verifyPackageRoot( - benchmarkFile.uri.toString(), - useDtd: useDtd, - ); + await verifyPackageRoot(benchmarkFile.uri.toString(), useDtd: useDtd); await verifyPackageRoot( benchmarkSubFile.uri.toString(), useDtd: useDtd, @@ -132,14 +125,20 @@ // Dart file in a nested project. await verifyPackageRoot( nestedProjectLibFile.uri.toString(), - expected: - p.posix.join(projectRootUriString, 'example', 'nested_project'), + expected: p.posix.join( + projectRootUriString, + 'example', + 'nested_project', + ), useDtd: useDtd, ); await verifyPackageRoot( nestedProjectTestFile.uri.toString(), - expected: - p.posix.join(projectRootUriString, 'example', 'nested_project'), + expected: p.posix.join( + projectRootUriString, + 'example', + 'nested_project', + ), useDtd: useDtd, ); @@ -201,19 +200,23 @@ /// foo_test.dart void _setupTestDirectoryStructure() { testDirectory = Directory.systemTemp.createTempSync(); - final projectRootDirectory = - Directory(p.joinAll([testDirectory.path, ...projectRootParts])) - ..createSync(recursive: true); - final projectRootDirectoryUriString = - Uri.file(projectRootDirectory.uri.toFilePath()).toString(); + final projectRootDirectory = Directory( + p.joinAll([testDirectory.path, ...projectRootParts]), + )..createSync(recursive: true); + final projectRootDirectoryUriString = Uri.file( + projectRootDirectory.uri.toFilePath(), + ).toString(); // Remove the trailing slash and set the value of [projectRoot]. projectRootUriString = projectRootDirectoryUriString.substring( - 0, projectRootDirectoryUriString.length - 1); + 0, + projectRootDirectoryUriString.length - 1, + ); // Set up the project root contents. - Directory(p.join(projectRootDirectory.path, '.dart_tool')) - .createSync(recursive: true); + Directory( + p.join(projectRootDirectory.path, '.dart_tool'), + ).createSync(recursive: true); libFile = File(p.join(projectRootDirectory.path, 'lib', 'foo.dart')) ..createSync(recursive: true); libSubFile = File(p.join(projectRootDirectory.path, 'lib', 'sub', 'foo.dart')) @@ -238,17 +241,17 @@ 'foo_test.dart', ), )..createSync(recursive: true); - benchmarkFile = - File(p.join(projectRootDirectory.path, 'benchmark', 'foo.dart')) - ..createSync(recursive: true); + benchmarkFile = File( + p.join(projectRootDirectory.path, 'benchmark', 'foo.dart'), + )..createSync(recursive: true); benchmarkSubFile = File( p.join(projectRootDirectory.path, 'benchmark', 'sub', 'foo.dart'), )..createSync(recursive: true); exampleFile = File(p.join(projectRootDirectory.path, 'example', 'foo.dart')) ..createSync(recursive: true); - exampleSubFile = - File(p.join(projectRootDirectory.path, 'example', 'sub', 'foo.dart')) - ..createSync(recursive: true); + exampleSubFile = File( + p.join(projectRootDirectory.path, 'example', 'sub', 'foo.dart'), + )..createSync(recursive: true); // Setup a nested Dart project under the 'example' directory. Directory( p.join( @@ -278,7 +281,7 @@ )..createSync(recursive: true); anyFile = File(p.join(projectRootDirectory.path, 'any_name', 'foo.dart')) ..createSync(recursive: true); - anySubFile = - File(p.join(projectRootDirectory.path, 'any_name', 'sub', 'foo.dart')) - ..createSync(recursive: true); + anySubFile = File( + p.join(projectRootDirectory.path, 'any_name', 'sub', 'foo.dart'), + )..createSync(recursive: true); }
diff --git a/packages/devtools_shared/test/utils/retry_test.dart b/packages/devtools_shared/test/utils/retry_test.dart index 1bad59f..1968f72 100644 --- a/packages/devtools_shared/test/utils/retry_test.dart +++ b/packages/devtools_shared/test/utils/retry_test.dart
@@ -52,15 +52,12 @@ test('throws after max retries reached', () async { expect(counter, 0); - await expectLater( - () async { - await runWithRetry( - callback: () => callback(succeedOnAttempt: 11), - maxRetries: 10, - ); - }, - throwsException, - ); + await expectLater(() async { + await runWithRetry( + callback: () => callback(succeedOnAttempt: 11), + maxRetries: 10, + ); + }, throwsException); expect(counter, 10); });
diff --git a/packages/devtools_test/lib/src/helpers/actions.dart b/packages/devtools_test/lib/src/helpers/actions.dart index f772168..39ed034 100644 --- a/packages/devtools_test/lib/src/helpers/actions.dart +++ b/packages/devtools_test/lib/src/helpers/actions.dart
@@ -36,8 +36,9 @@ findsOneWidget, shouldExpect: runWithExpectations, ); - final menuChildren = - controller.widget<MenuAnchor>(tabOverflowMenuFinder).menuChildren; + final menuChildren = controller + .widget<MenuAnchor>(tabOverflowMenuFinder) + .menuChildren; numTabs += menuChildren.length; } @@ -47,12 +48,12 @@ shouldExpect: runWithExpectations, ); - final expectedConnectedControllersCount = - devtoolsScreens!.where((s) => s.providesController).length; - final expectedDisconnectedControllersCount = - devtoolsScreens! - .where((s) => s.providesController && !s.screen.requiresConnection) - .length; + final expectedConnectedControllersCount = devtoolsScreens! + .where((s) => s.providesController) + .length; + final expectedDisconnectedControllersCount = devtoolsScreens! + .where((s) => s.providesController && !s.screen.requiresConnection) + .length; _maybeExpect( screenControllers.controllers.length, connectedToApp @@ -66,9 +67,8 @@ shouldExpect: runWithExpectations, ); - final screens = - (ScreenMetaData.values.toList() - ..removeWhere((data) => !visibleScreenIds.contains(data.id))); + final screens = (ScreenMetaData.values.toList() + ..removeWhere((data) => !visibleScreenIds.contains(data.id))); for (final screen in screens) { await switchToScreen( controller,
diff --git a/packages/devtools_test/lib/src/mocks/fake_service_extension_manager.dart b/packages/devtools_test/lib/src/mocks/fake_service_extension_manager.dart index 5be3b19..e9da257 100644 --- a/packages/devtools_test/lib/src/mocks/fake_service_extension_manager.dart +++ b/packages/devtools_test/lib/src/mocks/fake_service_extension_manager.dart
@@ -86,13 +86,12 @@ if (extension != null) { final value = _getExtensionValueFromJson(name, valueFromJson); - final enabled = - extension is ToggleableServiceExtension - ? value == extension.enabledValue - // For extensions that have more than two states - // (enabled / disabled), we will always consider them to be - // enabled with the current value. - : true; + final enabled = extension is ToggleableServiceExtension + ? value == extension.enabledValue + // For extensions that have more than two states + // (enabled / disabled), we will always consider them to be + // enabled with the current value. + : true; await setServiceExtensionState( name,
diff --git a/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart b/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart index 353bb76..d6a981e 100644 --- a/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart +++ b/packages/devtools_test/lib/src/mocks/fake_vm_service_wrapper.dart
@@ -45,17 +45,16 @@ } } - static final _defaultProfile = - CpuSamples.parse({ - 'samplePeriod': 50, - 'maxStackDepth': 12, - 'sampleCount': 0, - 'timeOriginMicros': 47377796685, - 'timeExtentMicros': 3000, - 'pid': 54321, - 'functions': <Object?>[], - 'samples': <Object?>[], - })!; + static final _defaultProfile = CpuSamples.parse({ + 'samplePeriod': 50, + 'maxStackDepth': 12, + 'sampleCount': 0, + 'timeOriginMicros': 47377796685, + 'timeExtentMicros': 3000, + 'pid': 54321, + 'functions': <Object?>[], + 'samples': <Object?>[], + })!; CpuSamples cpuSamples; @@ -132,10 +131,9 @@ Future<UriList> lookupPackageUris(String isolateId, List<String> uris) { return Future.value( UriList( - uris: - _resolvedUriMap != null - ? (uris.map((e) => _resolvedUriMap[e]).toList()) - : null, + uris: _resolvedUriMap != null + ? (uris.map((e) => _resolvedUriMap[e]).toList()) + : null, ), ); } @@ -148,10 +146,9 @@ }) { return Future.value( UriList( - uris: - _reverseResolvedUriMap != null - ? (uris.map((e) => _reverseResolvedUriMap[e]).toList()) - : null, + uris: _reverseResolvedUriMap != null + ? (uris.map((e) => _reverseResolvedUriMap[e]).toList()) + : null, ), ); } @@ -192,21 +189,21 @@ allocationProfile.json = allocationProfile.toJson(); // Fake GC statistics - allocationProfile.json![AllocationProfilePrivateViewExtension - .heapsKey] = <String, dynamic>{ - AllocationProfilePrivateViewExtension.newSpaceKey: <String, dynamic>{ - GCStats.usedKey: 1234, - GCStats.capacityKey: 12345, - GCStats.collectionsKey: 42, - GCStats.timeKey: 69, - }, - AllocationProfilePrivateViewExtension.oldSpaceKey: <String, dynamic>{ - GCStats.usedKey: 4321, - GCStats.capacityKey: 54321, - GCStats.collectionsKey: 24, - GCStats.timeKey: 96, - }, - }; + allocationProfile.json![AllocationProfilePrivateViewExtension.heapsKey] = + <String, dynamic>{ + AllocationProfilePrivateViewExtension.newSpaceKey: <String, dynamic>{ + GCStats.usedKey: 1234, + GCStats.capacityKey: 12345, + GCStats.collectionsKey: 42, + GCStats.timeKey: 69, + }, + AllocationProfilePrivateViewExtension.oldSpaceKey: <String, dynamic>{ + GCStats.usedKey: 4321, + GCStats.capacityKey: 54321, + GCStats.collectionsKey: 24, + GCStats.timeKey: 96, + }, + }; return Future.value(allocationProfile); }
diff --git a/tool/lib/commands/release_helper.dart b/tool/lib/commands/release_helper.dart index 7e9ded0..4e68d11 100644 --- a/tool/lib/commands/release_helper.dart +++ b/tool/lib/commands/release_helper.dart
@@ -59,15 +59,14 @@ if (debug) { // Temporarily commit any local changes to this script to the current // branch. This commit will be reset at the end of the script. - final pathToReleaseHelperScript = - Uri.parse( - p.posix.join( - DevToolsRepo.getInstance().toolDirectoryPath, - 'lib', - 'commands', - 'release_helper.dart', - ), - ).toFilePath(); + final pathToReleaseHelperScript = Uri.parse( + p.posix.join( + DevToolsRepo.getInstance().toolDirectoryPath, + 'lib', + 'commands', + 'release_helper.dart', + ), + ).toFilePath(); await processManager.runProcess( CliCommand.git(['add', pathToReleaseHelperScript]), );
diff --git a/tool/lib/commands/release_notes_helper.dart b/tool/lib/commands/release_notes_helper.dart index 5735e7a..6244836 100644 --- a/tool/lib/commands/release_notes_helper.dart +++ b/tool/lib/commands/release_notes_helper.dart
@@ -143,7 +143,8 @@ } } - final metadataHeader = '''--- + final metadataHeader = + '''--- title: DevTools $releaseNotesVersion release notes shortTitle: $releaseNotesVersion release notes breadcrumb: $releaseNotesVersion
diff --git a/tool/lib/commands/rollback.dart b/tool/lib/commands/rollback.dart index 04f39b9..de8c5e9 100644 --- a/tool/lib/commands/rollback.dart +++ b/tool/lib/commands/rollback.dart
@@ -27,14 +27,14 @@ final repo = DevToolsRepo.getInstance(); print('DevTools repo at ${repo.repoPath}.'); - final tempDir = - (await io.Directory.systemTemp.createTemp( - 'devtools-rollback', - )).absolute; + final tempDir = (await io.Directory.systemTemp.createTemp( + 'devtools-rollback', + )).absolute; print('file://${tempDir.path}'); final tarball = io.File('${tempDir.path}/devtools.tar.gz'); - final extractDir = - await io.Directory('${tempDir.path}/extract/').absolute.create(); + final extractDir = await io.Directory( + '${tempDir.path}/extract/', + ).absolute.create(); final client = io.HttpClient(); final version = argResults![_toVersionArg] as String; print('downloading tarball to ${tarball.path}');
diff --git a/tool/lib/commands/serve.dart b/tool/lib/commands/serve.dart index 6e3243e..9eb7cff 100644 --- a/tool/lib/commands/serve.dart +++ b/tool/lib/commands/serve.dart
@@ -174,29 +174,27 @@ } // Any flag that we aren't removing here is intended to be passed through. - final remainingArguments = - List.of(results.arguments) - ..remove(SharedCommandArgs.updateFlutter.asArg()) - ..remove(SharedCommandArgs.updateFlutter.asArg(negated: true)) - ..remove(SharedCommandArgs.updatePerfetto.asArg()) - ..remove(SharedCommandArgs.wasm.asArg()) - ..remove(SharedCommandArgs.noStripWasm.asArg()) - ..remove(SharedCommandArgs.noMinifyWasm.asArg()) - ..remove(valueAsArg(_buildAppFlag)) - ..remove(valueAsArg(_buildAppFlag, negated: true)) - ..remove(SharedCommandArgs.runApp.asArg()) - ..remove(SharedCommandArgs.debugServer.asArg()) - ..remove(SharedCommandArgs.pubGet.asArg()) - ..remove(SharedCommandArgs.pubGet.asArg(negated: true)) - ..removeWhere( - (element) => - element.startsWith(SharedCommandArgs.buildMode.asArg()), - ) - ..removeWhere( - (element) => element.startsWith( - valueAsArg(SharedCommandArgs.serveWithDartSdk.flagName), - ), - ); + final remainingArguments = List.of(results.arguments) + ..remove(SharedCommandArgs.updateFlutter.asArg()) + ..remove(SharedCommandArgs.updateFlutter.asArg(negated: true)) + ..remove(SharedCommandArgs.updatePerfetto.asArg()) + ..remove(SharedCommandArgs.wasm.asArg()) + ..remove(SharedCommandArgs.noStripWasm.asArg()) + ..remove(SharedCommandArgs.noMinifyWasm.asArg()) + ..remove(valueAsArg(_buildAppFlag)) + ..remove(valueAsArg(_buildAppFlag, negated: true)) + ..remove(SharedCommandArgs.runApp.asArg()) + ..remove(SharedCommandArgs.debugServer.asArg()) + ..remove(SharedCommandArgs.pubGet.asArg()) + ..remove(SharedCommandArgs.pubGet.asArg(negated: true)) + ..removeWhere( + (element) => element.startsWith(SharedCommandArgs.buildMode.asArg()), + ) + ..removeWhere( + (element) => element.startsWith( + valueAsArg(SharedCommandArgs.serveWithDartSdk.flagName), + ), + ); final localDartSdkLocation = Platform.environment['LOCAL_DART_SDK']; if (localDartSdkLocation == null) { @@ -271,11 +269,13 @@ void processServeLocalOutput(String line) { if (line.startsWith(_debugServerVmServiceLine)) { - debugServerVmServiceUri = - line.substring(_debugServerVmServiceLine.length).trim(); + debugServerVmServiceUri = line + .substring(_debugServerVmServiceLine.length) + .trim(); } else if (line.startsWith(_debugServerDartDevToolsLine)) { - debugServerDevToolsConnection = - line.substring(_debugServerDartDevToolsLine.length).trim(); + debugServerDevToolsConnection = line + .substring(_debugServerDartDevToolsLine.length) + .trim(); } else if (line.startsWith(_devToolsServerAddressLine)) { // This will pull the server address from a String like: // "Serving DevTools at http://127.0.0.1:9104.". @@ -344,12 +344,14 @@ void processFlutterRunOutput(String line) { if (line.contains(_runAppVmServiceLine)) { final index = line.indexOf(_runAppVmServiceLine); - devToolsWebAppVmServiceUri = - line.substring(index + _runAppVmServiceLine.length).trim(); + devToolsWebAppVmServiceUri = line + .substring(index + _runAppVmServiceLine.length) + .trim(); } else if (line.contains(_runAppFlutterDevToolsLine)) { final index = line.indexOf(_runAppFlutterDevToolsLine); - devToolsWebAppDevToolsConnection = - line.substring(index + _runAppFlutterDevToolsLine.length).trim(); + devToolsWebAppDevToolsConnection = line + .substring(index + _runAppFlutterDevToolsLine.length) + .trim(); } } @@ -371,13 +373,12 @@ ); // Consolidate important stdout content for easy access. - final debugServerContent = - debugServer - ? ''' + final debugServerContent = debugServer + ? ''' - VM Service URI: $debugServerVmServiceUri - DevTools URI for debugging the DevTools server: $debugServerDevToolsConnection ''' - : ''; + : ''; print(''' -------------------------------------------------------------------
diff --git a/tool/lib/commands/update_flutter_sdk.dart b/tool/lib/commands/update_flutter_sdk.dart index 81d5b08..ab11876 100644 --- a/tool/lib/commands/update_flutter_sdk.dart +++ b/tool/lib/commands/update_flutter_sdk.dart
@@ -49,10 +49,9 @@ final versionStr = repo.readFile(Uri.parse('flutter-candidate.txt')).trim(); // If the version string doesn't match the expected pattern for a // pre-release tag, then assume it's a commit hash: - flutterVersion = - _flutterPreReleaseTagRegExp.hasMatch(versionStr) - ? 'tags/$versionStr' - : versionStr; + flutterVersion = _flutterPreReleaseTagRegExp.hasMatch(versionStr) + ? 'tags/$versionStr' + : versionStr; log.stdout('Updating to Flutter version from cache: $flutterVersion');
diff --git a/tool/lib/commands/update_version.dart b/tool/lib/commands/update_version.dart index 099be52..02c829a 100644 --- a/tool/lib/commands/update_version.dart +++ b/tool/lib/commands/update_version.dart
@@ -142,14 +142,13 @@ } if (currentSection == pubspecVersionPrefix && line.startsWith(pubspecVersionPrefix)) { - line = - [ - line.substring( - 0, - line.indexOf(pubspecVersionPrefix) + pubspecVersionPrefix.length, - ), - ' $version', - ].join(); + line = [ + line.substring( + 0, + line.indexOf(pubspecVersionPrefix) + pubspecVersionPrefix.length, + ), + ' $version', + ].join(); } revisedLines.add(line); }
diff --git a/tool/lib/license_utils.dart b/tool/lib/license_utils.dart index 652e90e..d1d4fb1 100644 --- a/tool/lib/license_utils.dart +++ b/tool/lib/license_utils.dart
@@ -202,10 +202,9 @@ .openRead(0, byteCount) .transform(utf8.decoder) .handleError( - (e) => - throw StateError( - 'License header expected, but error reading file - $e', - ), + (e) => throw StateError( + 'License header expected, but error reading file - $e', + ), ); await for (final content in stream) { // Return just the license headers for the simple case with no stored @@ -270,8 +269,10 @@ }) async { final includedPathsList = <String>[]; final updatedPathsList = <String>[]; - final files = - directory.listSync(recursive: true).whereType<File>().toList(); + final files = directory + .listSync(recursive: true) + .whereType<File>() + .toList(); for (final file in files) { if (!config.shouldExclude(file)) { includedPathsList.add(file.path); @@ -332,10 +333,9 @@ final storedNameIndex = matchStr.indexOf('<$storedName>'); if (storedNameIndex != -1) { final beforeStoredName = matchStr.substring(0, storedNameIndex); - final afterStoredName = - matchStr - .substring(storedNameIndex + storedName.length + 2) - .trimRight(); + final afterStoredName = matchStr + .substring(storedNameIndex + storedName.length + 2) + .trimRight(); final storedMatcher = RegExp( r'' + beforeStoredName +
diff --git a/tool/lib/model.dart b/tool/lib/model.dart index ecba1f5..2032b4c 100644 --- a/tool/lib/model.dart +++ b/tool/lib/model.dart
@@ -114,21 +114,20 @@ // Do not include the top level devtools/packages directory in the results // even though it has a pubspec.yaml file. Also skip any directories // specified by [skip]. - final reason = - isTopLevelPackagesDir - ? 'each DevTools package is analyzed individually' - : '${skip.toString()} directories are intentionally skipped'; + final reason = isTopLevelPackagesDir + ? 'each DevTools package is analyzed individually' + : '${skip.toString()} directories are intentionally skipped'; print('Skipping ${dir.path} in _collectPackages because $reason.'); } else { final ancestor = result.firstWhereOrNull( (p) => - // Remove the last segment of [dir]'s pathSegments to ensure we - // are only checking ancestors and not sibling directories with - // similar names. - (List.from(dir.uri.pathSegments)..safeRemoveLast()) - // TODO(kenz): this may cause issues for Windows paths. - .join('/') - .startsWith(p.packagePath), + // Remove the last segment of [dir]'s pathSegments to ensure we + // are only checking ancestors and not sibling directories with + // similar names. + (List.from(dir.uri.pathSegments)..safeRemoveLast()) + // TODO(kenz): this may cause issues for Windows paths. + .join('/') + .startsWith(p.packagePath), ); final ancestorDirectoryAdded = ancestor != null; if (!includeSubdirectories && ancestorDirectoryAdded) {
diff --git a/tool/lib/utils.dart b/tool/lib/utils.dart index 467bea8..bc8d85a 100644 --- a/tool/lib/utils.dart +++ b/tool/lib/utils.dart
@@ -257,8 +257,8 @@ try { upstreamRemoteResult = remoteRegexpResults.firstWhere( (element) => - // ignore: prefer_interpolation_to_compose_strings - RegExp(r'' + remoteId + '\$').hasMatch(element.namedGroup('path')!), + // ignore: prefer_interpolation_to_compose_strings + RegExp(r'' + remoteId + '\$').hasMatch(element.namedGroup('path')!), ); } on StateError { throw StateError(
diff --git a/tool/test/license_utils_test.dart b/tool/test/license_utils_test.dart index 5cbd217..269d00c 100644 --- a/tool/test/license_utils_test.dart +++ b/tool/test/license_utils_test.dart
@@ -420,8 +420,10 @@ true, reason: '$checkedDirectory does not exist.', ); - final files = - checkedDirectory.listSync(recursive: true).whereType<File>().toList(); + final files = checkedDirectory + .listSync(recursive: true) + .whereType<File>() + .toList(); final header = LicenseHeader(); const goodReplacementLicenseText = '''// Copyright <copyright_date> The Flutter Authors @@ -480,7 +482,8 @@ configFile = File(p.join(testDirectory.path, 'test_config.yaml')) ..createSync(recursive: true); - final contents = '''--- + final contents = + '''--- # sequence of license text strings that should be matched against at the top of a file and removed. <value>, which normally represents a date, will be stored. remove_licenses: - |
diff --git a/tool/test/presubmit_test.dart b/tool/test/presubmit_test.dart index fff0813..1f00f28 100644 --- a/tool/test/presubmit_test.dart +++ b/tool/test/presubmit_test.dart
@@ -39,18 +39,19 @@ final capturedArgs = <List<String>>[]; final mockPm = MockProcessManager( - onSpawn: ( - executable, - arguments, { - workingDirectory, - environment, - includeParentEnvironment = true, - runInShell = false, - mode = ProcessStartMode.normal, - }) async { - capturedArgs.add(arguments.toList()); - return MockProcess(); - }, + onSpawn: + ( + executable, + arguments, { + workingDirectory, + environment, + includeParentEnvironment = true, + runInShell = false, + mode = ProcessStartMode.normal, + }) async { + capturedArgs.add(arguments.toList()); + return MockProcess(); + }, ); runner.addCommand(PresubmitCommand(processManager: mockPm)); @@ -110,21 +111,22 @@ runner.addDummyCommand('analyze'); final mockPm = MockProcessManager( - onSpawn: ( - executable, - arguments, { - workingDirectory, - environment, - includeParentEnvironment = true, - runInShell = false, - mode = ProcessStartMode.normal, - }) async { - if (arguments.contains('format') && - arguments.contains('--set-exit-if-changed')) { - return MockProcess(exitCodeValue: 1); - } - return MockProcess(); - }, + onSpawn: + ( + executable, + arguments, { + workingDirectory, + environment, + includeParentEnvironment = true, + runInShell = false, + mode = ProcessStartMode.normal, + }) async { + if (arguments.contains('format') && + arguments.contains('--set-exit-if-changed')) { + return MockProcess(exitCodeValue: 1); + } + return MockProcess(); + }, ); runner.addCommand(PresubmitCommand(processManager: mockPm)); @@ -141,18 +143,19 @@ final capturedArgs = <List<String>>[]; final mockPm = MockProcessManager( - onSpawn: ( - executable, - arguments, { - workingDirectory, - environment, - includeParentEnvironment = true, - runInShell = false, - mode = ProcessStartMode.normal, - }) async { - capturedArgs.add(arguments.toList()); - return MockProcess(); - }, + onSpawn: + ( + executable, + arguments, { + workingDirectory, + environment, + includeParentEnvironment = true, + runInShell = false, + mode = ProcessStartMode.normal, + }) async { + capturedArgs.add(arguments.toList()); + return MockProcess(); + }, ); runner.addCommand(PresubmitCommand(processManager: mockPm));