We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
ChannelPostPolicy.fromInt
1 parent 73fc7e9 commit 4eed88cCopy full SHA for 4eed88c
lib/api/model/model.dart
@@ -378,6 +378,17 @@ enum ChannelPostPolicy {
378
final int? apiValue;
379
380
int? toJson() => apiValue;
381
+
382
+ /// Get a [ChannelPostPolicy] from a nullable int.
383
+ ///
384
+ /// Example:
385
+ /// 2 -> ChannelPostPolicy.administrators
386
+ /// null -> ChannelPostPolicy.unknown
387
+ static ChannelPostPolicy fromInt(int? value) => _byIntValue[value]!;
388
389
+ // _$…EnumMap is thanks to `alwaysCreate: true` and `fieldRename: FieldRename.kebab`
390
+ static final _byIntValue = _$ChannelPostPolicyEnumMap
391
+ .map((key, value) => MapEntry(value, key));
392
}
393
394
/// As in `subscriptions` in the initial snapshot.
0 commit comments