refactor(mobile): Use switch expression when possible (#15852)

refactor: Use `switch` expression when possible

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Damiano Ferrari 2025-02-02 22:46:46 +01:00 committed by GitHub
parent 4efacfbb91
commit 96a6cc20b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 219 additions and 374 deletions

View file

@ -545,19 +545,13 @@ enum AssetType {
}
extension AssetTypeEnumHelper on AssetTypeEnum {
AssetType toAssetType() {
switch (this) {
case AssetTypeEnum.IMAGE:
return AssetType.image;
case AssetTypeEnum.VIDEO:
return AssetType.video;
case AssetTypeEnum.AUDIO:
return AssetType.audio;
case AssetTypeEnum.OTHER:
return AssetType.other;
}
throw Exception();
}
AssetType toAssetType() => switch (this) {
AssetTypeEnum.IMAGE => AssetType.image,
AssetTypeEnum.VIDEO => AssetType.video,
AssetTypeEnum.AUDIO => AssetType.audio,
AssetTypeEnum.OTHER => AssetType.other,
_ => throw Exception(),
};
}
/// Describes where the information of this asset came from: