Implement switch expressions in dev/ (#139048)

I previously made a PR (#136140) that used `switch` expressions to make some parts of the Flutter codebase easier to understand. It was assigned to the framework team, and @christopherfujino let me know that it was too large to effectively review and recommended breaking it up into smaller pull requests.

Here's a PR that only targets files in the `dev/` directory. Hopefully this will be easier to work with!

(solves issue https://github.com/flutter/flutter/issues/136139)
This commit is contained in:
Nate
2023-11-28 16:40:28 -07:00
committed by GitHub
parent 9c4df1f1f5
commit 3267fbc07a
15 changed files with 117 additions and 197 deletions

View File

@@ -47,12 +47,10 @@ class Remote {
/// The name of the remote.
String get name {
switch (_name) {
case RemoteName.upstream:
return 'upstream';
case RemoteName.mirror:
return 'mirror';
}
return switch (_name) {
RemoteName.upstream => 'upstream',
RemoteName.mirror => 'mirror',
};
}
/// The URL of the remote.

View File

@@ -295,15 +295,11 @@ class Version {
@override
String toString() {
switch (type) {
case VersionType.stable:
return '$x.$y.$z';
case VersionType.development:
return '$x.$y.$z-$m.$n.pre';
case VersionType.latest:
return '$x.$y.$z-$m.$n.pre.$commits';
case VersionType.gitDescribe:
return '$x.$y.$z-$m.$n.pre.$commits';
}
return switch (type) {
VersionType.stable => '$x.$y.$z',
VersionType.development => '$x.$y.$z-$m.$n.pre',
VersionType.latest => '$x.$y.$z-$m.$n.pre.$commits',
VersionType.gitDescribe => '$x.$y.$z-$m.$n.pre.$commits',
};
}
}