Skip to content

Commit 20b6936

Browse files
authored
Reformat all code with recent Flutter/Dart SDK (flutter#9871)
1 parent 140594b commit 20b6936

97 files changed

Lines changed: 2096 additions & 2564 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/devtools_app_shared/example/service_example.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ void main() async {
4040
);
4141

4242
/// Example: Get a service extension state.
43-
final performanceOverlayEnabled =
44-
serviceManager.serviceExtensionManager.getServiceExtensionState(
45-
extensions.performanceOverlay.extension,
46-
);
43+
final performanceOverlayEnabled = serviceManager.serviceExtensionManager
44+
.getServiceExtensionState(extensions.performanceOverlay.extension);
4745

4846
// Example: Set a service extension state.
4947
await serviceManager.serviceExtensionManager.setServiceExtensionState(

packages/devtools_app_shared/example/ui/split_example.dart

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ class SplitExample extends StatelessWidget {
2020
axis: Axis.horizontal,
2121
initialFractions: const [0.3, 0.7],
2222
minSizes: const [50.0, 100.0],
23-
children: const [
24-
Text('Left side'),
25-
Text('Right side'),
26-
],
23+
children: const [Text('Left side'), Text('Right side')],
2724
);
2825
}
2926
}
@@ -42,15 +39,8 @@ class MultiSplitExample extends StatelessWidget {
4239
axis: Axis.vertical,
4340
initialFractions: const [0.3, 0.3, 0.4],
4441
minSizes: const [50.0, 50.0, 100.0],
45-
splitters: const [
46-
CustomSplitter(),
47-
CustomSplitter(),
48-
],
49-
children: const [
50-
Text('Top'),
51-
Text('Middle'),
52-
Text('Bottom'),
53-
],
42+
splitters: const [CustomSplitter(), CustomSplitter()],
43+
children: const [Text('Top'), Text('Middle'), Text('Bottom')],
5444
);
5545
}
5646
}
@@ -62,10 +52,7 @@ class CustomSplitter extends StatelessWidget implements PreferredSizeWidget {
6252

6353
@override
6454
Widget build(BuildContext context) {
65-
return const SizedBox(
66-
height: _size,
67-
child: Icon(Icons.front_hand),
68-
);
55+
return const SizedBox(height: _size, child: Icon(Icons.front_hand));
6956
}
7057

7158
@override

packages/devtools_app_shared/lib/src/service/connected_app.dart

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ class ConnectedApp {
5252
String? _operatingSystem;
5353

5454
// TODO(kenz): investigate if we can use `libraryUriAvailableNow` instead.
55-
Future<bool> get isFlutterApp async => _isFlutterApp ??=
56-
await serviceManager!.libraryUriAvailable(flutterLibraryUri);
55+
Future<bool> get isFlutterApp async => _isFlutterApp ??= await serviceManager!
56+
.libraryUriAvailable(flutterLibraryUri);
5757

5858
bool? get isFlutterAppNow {
5959
assert(_isFlutterApp != null);
@@ -85,8 +85,8 @@ class ConnectedApp {
8585
bool? _isProfileBuild;
8686

8787
// TODO(kenz): investigate if we can use `libraryUriAvailableNow` instead.
88-
Future<bool> get isDartWebApp async => _isDartWebApp ??=
89-
await serviceManager!.libraryUriAvailable(dartHtmlLibraryUri);
88+
Future<bool> get isDartWebApp async => _isDartWebApp ??= await serviceManager!
89+
.libraryUriAvailable(dartHtmlLibraryUri);
9090

9191
bool? get isDartWebAppNow {
9292
assert(_isDartWebApp != null);
@@ -189,14 +189,14 @@ class ConnectedApp {
189189
}
190190

191191
Map<String, Object?> toJson() => {
192-
isFlutterAppKey: isFlutterAppNow,
193-
isProfileBuildKey: isProfileBuildNow,
194-
isDartWebAppKey: isDartWebAppNow,
195-
isRunningOnDartVMKey: isRunningOnDartVM,
196-
operatingSystemKey: operatingSystem,
197-
if (flutterVersionNow != null && !flutterVersionNow!.unknown)
198-
flutterVersionKey: flutterVersionNow!.version,
199-
};
192+
isFlutterAppKey: isFlutterAppNow,
193+
isProfileBuildKey: isProfileBuildNow,
194+
isDartWebAppKey: isDartWebAppNow,
195+
isRunningOnDartVMKey: isRunningOnDartVM,
196+
operatingSystemKey: operatingSystem,
197+
if (flutterVersionNow != null && !flutterVersionNow!.unknown)
198+
flutterVersionKey: flutterVersionNow!.version,
199+
};
200200
}
201201

202202
final class OfflineConnectedApp extends ConnectedApp {
@@ -215,7 +215,8 @@ final class OfflineConnectedApp extends ConnectedApp {
215215
isProfileBuildNow: json[ConnectedApp.isProfileBuildKey] as bool?,
216216
isDartWebAppNow: json[ConnectedApp.isDartWebAppKey] as bool?,
217217
isRunningOnDartVM: json[ConnectedApp.isRunningOnDartVMKey] as bool?,
218-
operatingSystem: (json[ConnectedApp.operatingSystemKey] as String?) ??
218+
operatingSystem:
219+
(json[ConnectedApp.operatingSystemKey] as String?) ??
219220
ConnectedApp.unknownOS,
220221
);
221222
}

packages/devtools_app_shared/lib/src/service/dtd_manager.dart

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ class DTDManager {
2525

2626
/// The current state of the connection.
2727
ValueListenable<DTDConnectionState> get connectionState => _connectionState;
28-
final _connectionState =
29-
ValueNotifier<DTDConnectionState>(NotConnectedDTDState());
28+
final _connectionState = ValueNotifier<DTDConnectionState>(
29+
NotConnectedDTDState(),
30+
);
3031

3132
/// The URI of the current DTD connection.
3233
Uri? get uri => _uri;
@@ -77,13 +78,15 @@ class DTDManager {
7778
//
7879
// If this happens, just disconnect (without disabling reconnect) so the
7980
// done event fires and then the usual handling occurs.
80-
_periodicConnectionCheck =
81-
Timer.periodic(_periodicConnectionCheckInterval, (timer) async {
82-
if (_dtd.isClosed) {
83-
_log.warning('The DTD connection has dropped');
84-
await disconnectImpl(allowReconnect: true);
85-
}
86-
});
81+
_periodicConnectionCheck = Timer.periodic(
82+
_periodicConnectionCheckInterval,
83+
(timer) async {
84+
if (_dtd.isClosed) {
85+
_log.warning('The DTD connection has dropped');
86+
await disconnectImpl(allowReconnect: true);
87+
}
88+
},
89+
);
8790

8891
return dtd;
8992
}
@@ -182,12 +185,16 @@ class DTDManager {
182185
// If a connection drops (and we hadn't disabled auto-reconnect, such
183186
// as by explicitly calling disconnect/dispose), we should attempt to
184187
// reconnect.
185-
unawaited(connection.done
186-
.then((_) => _reconnectAfterDroppedConnection(uri, onError: onError))
187-
.catchError((_) {
188-
// TODO(dantup): Create a devtools_app_shared version of safeUnawaited.
189-
// https://github.com/flutter/devtools/pull/9587#discussion_r2624306047
190-
}));
188+
unawaited(
189+
connection.done
190+
.then(
191+
(_) => _reconnectAfterDroppedConnection(uri, onError: onError),
192+
)
193+
.catchError((_) {
194+
// TODO(dantup): Create a devtools_app_shared version of safeUnawaited.
195+
// https://github.com/flutter/devtools/pull/9587#discussion_r2624306047
196+
}),
197+
);
191198
} catch (e, st) {
192199
onError?.call(e, st);
193200
}
@@ -229,8 +236,8 @@ class DTDManager {
229236
}) {
230237
// On explicit connections, we capture the connect function so that we
231238
// can call it again if [reconnect()] is called.
232-
final connectFunc = _lastConnectFunc =
233-
() => _connectImpl(uri, onError: onError, maxRetries: maxRetries);
239+
final connectFunc = _lastConnectFunc = () =>
240+
_connectImpl(uri, onError: onError, maxRetries: maxRetries);
234241
return connectFunc();
235242
}
236243

@@ -284,15 +291,18 @@ class DTDManager {
284291

285292
/// Listens for service registration events on the [dtd] connection.
286293
Future<void> _listenForServiceRegistrationEvents(
287-
DartToolingDaemon dtd) async {
294+
DartToolingDaemon dtd,
295+
) async {
288296
// We immediately begin listening for service registration events on the new
289297
// DTD connection before canceling the previous subscription. This
290298
// guarantees that we don't miss any events across reconnects.
291299
// ignore: cancel_subscriptions, false positive, it is canceled below.
292300
final nextServiceRegistrationSubscription = dtd
293301
.onEvent(CoreDtdServiceConstants.servicesStreamId)
294-
.listen(_forwardServiceRegistrationEvents,
295-
onError: _logServiceStreamError);
302+
.listen(
303+
_forwardServiceRegistrationEvents,
304+
onError: _logServiceStreamError,
305+
);
296306
await dtd.streamListen(CoreDtdServiceConstants.servicesStreamId);
297307

298308
// Cancel the previous subscription.
@@ -307,7 +317,7 @@ class DTDManager {
307317
final kind = event.kind;
308318
final isRegistrationEvent =
309319
kind == CoreDtdServiceConstants.serviceRegisteredKind ||
310-
kind == CoreDtdServiceConstants.serviceUnregisteredKind;
320+
kind == CoreDtdServiceConstants.serviceUnregisteredKind;
311321

312322
if (isRegistrationEvent) {
313323
_serviceRegistrationController.add(event);

packages/devtools_app_shared/lib/src/service/eval_on_dart_library.dart

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ class EvalOnDartLibrary extends DisposableController
105105
}
106106

107107
try {
108-
final isolate =
109-
await serviceManager.isolateManager.isolateState(isolateRef).isolate;
108+
final isolate = await serviceManager.isolateManager
109+
.isolateState(isolateRef)
110+
.isolate;
110111
if (_currentRequestId != requestId) {
111112
// The initialize request is obsolete.
112113
return;
@@ -150,11 +151,7 @@ class EvalOnDartLibrary extends DisposableController
150151
}
151152
return await addRequest<InstanceRef?>(
152153
isAlive,
153-
() => _eval(
154-
expression,
155-
scope: scope,
156-
shouldLogError: shouldLogError,
157-
),
154+
() => _eval(expression, scope: scope, shouldLogError: shouldLogError),
158155
);
159156
}
160157

@@ -626,12 +623,14 @@ class EvalOnDartLibrary extends DisposableController
626623
int? count,
627624
}) {
628625
return addRequest<T>(isAlive, () async {
629-
final T value = await service.getObject(
630-
_isolateRef!.id!,
631-
instance.id!,
632-
offset: offset,
633-
count: count,
634-
) as T;
626+
final T value =
627+
await service.getObject(
628+
_isolateRef!.id!,
629+
instance.id!,
630+
offset: offset,
631+
count: count,
632+
)
633+
as T;
635634
return value;
636635
});
637636
}

packages/devtools_app_shared/lib/src/service/flutter_version.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ final class FlutterVersion extends SemanticVersion {
9494

9595
@override
9696
int get hashCode => Object.hash(
97-
version,
98-
channel,
99-
repositoryUrl,
100-
frameworkRevision,
101-
frameworkCommitDate,
102-
engineRevision,
103-
dartSdkVersion,
104-
);
97+
version,
98+
channel,
99+
repositoryUrl,
100+
frameworkRevision,
101+
frameworkCommitDate,
102+
engineRevision,
103+
dartSdkVersion,
104+
);
105105

106106
static final _stableVersionRegex = RegExp(r'^\d+\.\d+\.\d+$');
107107
static final _isNumericRegex = RegExp(r'\d');

packages/devtools_app_shared/lib/src/service/isolate_state.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class IsolateState {
3434
void handleIsolateLoad(Isolate isolate) {
3535
_isolateNow = isolate;
3636

37-
_isPaused.value = isolate.pauseEvent != null &&
37+
_isPaused.value =
38+
isolate.pauseEvent != null &&
3839
isolate.pauseEvent!.kind != EventKind.kResume;
3940

4041
rootInfo = RootInfo(_isolateNow!.rootLib?.uri);

packages/devtools_app_shared/lib/src/service/resolved_uri_manager.dart

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ final class ResolvedUriManager {
3131
Future<void> fetchPackageUris(String isolateId, List<String> uris) async {
3232
if (uris.isEmpty) return;
3333
if (_packagePathMappings != null) {
34-
final packageUris =
35-
(await _service!.lookupPackageUris(isolateId, uris)).uris;
34+
final packageUris = (await _service!.lookupPackageUris(
35+
isolateId,
36+
uris,
37+
)).uris;
3638

3739
if (packageUris != null) {
3840
_packagePathMappings!.addMappings(
@@ -54,9 +56,10 @@ final class ResolvedUriManager {
5456
/// * [packageUris] - List of URIs to fetch full file paths for.
5557
Future<void> fetchFileUris(String isolateId, List<String> packageUris) async {
5658
if (_packagePathMappings != null) {
57-
final fileUris =
58-
(await _service!.lookupResolvedPackageUris(isolateId, packageUris))
59-
.uris;
59+
final fileUris = (await _service!.lookupResolvedPackageUris(
60+
isolateId,
61+
packageUris,
62+
)).uris;
6063

6164
// [_packagePathMappings] could have been set to null during the async gap
6265
// so check that it is non-null again here.
@@ -95,15 +98,11 @@ class _PackagePathMappings {
9598
String? lookupPackageToFullPathMapping(
9699
String isolateId,
97100
String packagePath,
98-
) =>
99-
_isolatePackageToFullPathMappings[isolateId]?[packagePath];
101+
) => _isolatePackageToFullPathMappings[isolateId]?[packagePath];
100102

101103
/// Returns the full path to package path mapping if it has already
102104
/// been fetched.
103-
String? lookupFullPathToPackageMapping(
104-
String isolateId,
105-
String fullPath,
106-
) =>
105+
String? lookupFullPathToPackageMapping(String isolateId, String fullPath) =>
107106
_isolateFullPathToPackageMappings[isolateId]?[fullPath];
108107

109108
/// Saves the mappings of [fullPaths] to [packagePaths].
@@ -118,16 +117,10 @@ class _PackagePathMappings {
118117
required List<String?> packagePaths,
119118
}) {
120119
assert(fullPaths.length == packagePaths.length);
121-
final fullPathToPackageMappings =
122-
_isolateFullPathToPackageMappings.putIfAbsent(
123-
isolateId,
124-
() => <String, String?>{},
125-
);
126-
final packageToFullPathMappings =
127-
_isolatePackageToFullPathMappings.putIfAbsent(
128-
isolateId,
129-
() => <String, String?>{},
130-
);
120+
final fullPathToPackageMappings = _isolateFullPathToPackageMappings
121+
.putIfAbsent(isolateId, () => <String, String?>{});
122+
final packageToFullPathMappings = _isolatePackageToFullPathMappings
123+
.putIfAbsent(isolateId, () => <String, String?>{});
131124

132125
assert(fullPaths.length == packagePaths.length);
133126

0 commit comments

Comments
 (0)