Implementing switch expressions in flutter_tools/ (#145632)
This pull request is step 12 in the journey to make this entire repository more readable. (previous PRs: #139048, #139882, #141591, #142279, #142634, #142793, #143293, #143496, #143634, #143812, #144580) We're getting close to the end! ð
This commit is contained in:
@@ -20,23 +20,15 @@ enum HttpMethod {
|
||||
}
|
||||
|
||||
HttpMethod _fromMethodString(String value) {
|
||||
final String name = value.toLowerCase();
|
||||
switch (name) {
|
||||
case 'get':
|
||||
return HttpMethod.get;
|
||||
case 'put':
|
||||
return HttpMethod.put;
|
||||
case 'delete':
|
||||
return HttpMethod.delete;
|
||||
case 'post':
|
||||
return HttpMethod.post;
|
||||
case 'patch':
|
||||
return HttpMethod.patch;
|
||||
case 'head':
|
||||
return HttpMethod.head;
|
||||
default:
|
||||
throw StateError('Unrecognized HTTP method $value');
|
||||
}
|
||||
return switch (value.toLowerCase()) {
|
||||
'get' => HttpMethod.get,
|
||||
'put' => HttpMethod.put,
|
||||
'delete' => HttpMethod.delete,
|
||||
'post' => HttpMethod.post,
|
||||
'patch' => HttpMethod.patch,
|
||||
'head' => HttpMethod.head,
|
||||
_ => throw StateError('Unrecognized HTTP method $value'),
|
||||
};
|
||||
}
|
||||
|
||||
String _toMethodString(HttpMethod method) {
|
||||
|
||||
Reference in New Issue
Block a user