We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
ChannelPostPolicy.fromInt
1 parent 32b301c commit 5a9abd5Copy full SHA for 5a9abd5
lib/api/model/model.dart
@@ -382,6 +382,17 @@ enum ChannelPostPolicy {
382
final int? apiValue;
383
384
int? toJson() => apiValue;
385
+
386
+ /// Get a [ChannelPostPolicy] from a nullable int.
387
+ ///
388
+ /// Example:
389
+ /// 2 -> ChannelPostPolicy.administrators
390
+ /// null -> ChannelPostPolicy.unknown
391
+ static ChannelPostPolicy fromInt(int? value) => _byIntValue[value]!;
392
393
+ // _$…EnumMap is thanks to `alwaysCreate: true` and `fieldRename: FieldRename.kebab`
394
+ static final _byIntValue = _$ChannelPostPolicyEnumMap
395
+ .map((key, value) => MapEntry(value, key));
396
}
397
398
/// As in `subscriptions` in the initial snapshot.
0 commit comments