forked from firka/flutter
Implementing null-aware operators throughout the repository (#143804)
This pull request fixes #143803 by taking advantage of Dart's null-aware operators. And unlike `switch` expressions ([9 PRs](https://github.com/flutter/flutter/pull/143634) and counting), the Flutter codebase is already fantastic when it comes to null-aware coding. After refactoring the entire repo, all the changes involving `?.` and `??` can fit into a single pull request.
This commit is contained in:
@@ -32,11 +32,7 @@ Future<void> main() async {
|
||||
final TaskResult? firstInstallFailure = testResults
|
||||
.firstWhereOrNull((TaskResult element) => element.failed);
|
||||
|
||||
if (firstInstallFailure != null) {
|
||||
return firstInstallFailure;
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
return firstInstallFailure ?? TaskResult.success(null);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -32,11 +32,7 @@ Future<void> main() async {
|
||||
final TaskResult? firstInstallFailure = testResults
|
||||
.firstWhereOrNull((TaskResult element) => element.failed);
|
||||
|
||||
if (firstInstallFailure != null) {
|
||||
return firstInstallFailure;
|
||||
}
|
||||
|
||||
return TaskResult.success(null);
|
||||
return firstInstallFailure ?? TaskResult.success(null);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -572,12 +572,7 @@ class BlinkTraceEvent {
|
||||
/// Returns null if the value is null.
|
||||
int? _readInt(Map<String, dynamic> json, String key) {
|
||||
final num? jsonValue = json[key] as num?;
|
||||
|
||||
if (jsonValue == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jsonValue.toInt();
|
||||
return jsonValue?.toInt();
|
||||
}
|
||||
|
||||
/// Used by [Chrome.launch] to detect a glibc bug and retry launching the
|
||||
|
||||
@@ -1290,11 +1290,7 @@ class PerfTest {
|
||||
}) {
|
||||
return inDirectory<TaskResult>(testDirectory, () async {
|
||||
late Device selectedDevice;
|
||||
if (device != null) {
|
||||
selectedDevice = device!;
|
||||
} else {
|
||||
selectedDevice = await devices.workingDevice;
|
||||
}
|
||||
selectedDevice = device ?? await devices.workingDevice;
|
||||
await selectedDevice.unlock();
|
||||
final String deviceId = selectedDevice.deviceId;
|
||||
final String? localEngine = localEngineFromEnv;
|
||||
|
||||
Reference in New Issue
Block a user