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:
@@ -206,16 +206,12 @@ class DriverTestMessage {
|
||||
|
||||
/// Return a DriverTestMessage depending on `status`.
|
||||
static DriverTestMessage fromString(String status) {
|
||||
switch (status) {
|
||||
case 'error':
|
||||
return DriverTestMessage.error();
|
||||
case 'pending':
|
||||
return DriverTestMessage.pending();
|
||||
case 'complete':
|
||||
return DriverTestMessage.complete();
|
||||
default:
|
||||
throw StateError('This type of status does not exist: $status');
|
||||
}
|
||||
return switch (status) {
|
||||
'error' => DriverTestMessage.error(),
|
||||
'pending' => DriverTestMessage.pending(),
|
||||
'complete' => DriverTestMessage.complete(),
|
||||
_ => throw StateError('This type of status does not exist: $status'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user