switch statement cleanup (#148382)

This PR is step 12 in the journey to solve issue #136139 and make the
entire Flutter repo more readable.

Most of it involves implementing switch expressions, and there's also a
few other random things that I wanted to clean up a bit.
This commit is contained in:
Nate
2024-05-16 18:16:06 -06:00
committed by GitHub
parent c4ad1dc1e9
commit fa9992eff6
39 changed files with 301 additions and 529 deletions

View File

@@ -115,15 +115,11 @@ class ABTest {
if (value == null) {
value = ''.padRight(len);
} else {
switch (aligns[column]) {
case FieldJustification.LEFT:
value = value.padRight(len);
case FieldJustification.RIGHT:
value = value.padLeft(len);
case FieldJustification.CENTER:
value = value.padLeft((len + value.length) ~/2);
value = value.padRight(len);
}
value = switch (aligns[column]) {
FieldJustification.LEFT => value.padRight(len),
FieldJustification.RIGHT => value.padLeft(len),
FieldJustification.CENTER => value.padLeft((len + value.length) ~/ 2).padRight(len),
};
}
if (column > 0) {
value = value.padLeft(len+1);

View File

@@ -252,14 +252,11 @@ class AndroidDeviceDiscovery implements DeviceDiscovery {
}
Future<bool> _matchesCPURequirement(AndroidDevice device) async {
switch (cpu) {
case null:
return true;
case AndroidCPU.arm64:
return device.isArm64();
case AndroidCPU.arm:
return device.isArm();
}
return switch (cpu) {
null => Future<bool>.value(true),
AndroidCPU.arm64 => device.isArm64(),
AndroidCPU.arm => device.isArm(),
};
}
/// Picks a random Android device out of connected devices and sets it as