-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgiphy_file_format.dart
38 lines (36 loc) · 1.21 KB
/
giphy_file_format.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/// An enumeration representing different file formats for Giphy content.
enum GiphyFileFormat {
gif,
mp4,
webp,
}
/// Extension methods for [GiphyFileFormat] to convert from and to string values.
extension GiphyFileFormatExtension on GiphyFileFormat {
/// Converts a string value to a corresponding [GiphyFileFormat] enum value.
///
/// Throws an [ArgumentError] if the given string does not match any [GiphyFileFormat] values.
///
/// [value] The string representation of the Giphy file format.
///
/// Returns the matching [GiphyFileFormat] value.
static GiphyFileFormat fromStringValue(String value) {
switch (value) {
case 'gif':
return GiphyFileFormat.gif;
case 'mp4':
return GiphyFileFormat.mp4;
case 'webp':
return GiphyFileFormat.webp;
default:
throw ArgumentError('Unknown GiphyFileFormat value: $value');
}
}
/// Converts a [GiphyFileFormat] enum value to its string representation.
///
/// [type] The [GiphyFileFormat] value to be converted.
///
/// Returns the string representation of the given [GiphyFileFormat] value.
static String toStringValue(GiphyFileFormat type) {
return type.toString().split('.').last;
}
}