protected<T extends Enum> static method

Future<TSharedprotectedEnumPod<T>> protected<T extends Enum>(
  1. String key,
  2. Iterable<T?> options, {
  3. T? initialValue,
})

Implementation

static Future<TSharedprotectedEnumPod<T>> protected<T extends Enum>(
  String key,
  Iterable<T?> options, {
  T? initialValue,
}) async {
  final instance = TSharedprotectedEnumPod<T>(
    key,
    fromValue: (value) {
      return options.firstWhere(
        (e) => e?.name.toLowerCase() == value?.toLowerCase(),
        orElse: () => null,
      );
    },
    toValue: (rawValue) => rawValue?.name,
    initialValue: initialValue,
  );
  await instance.refresh();
  return instance;
}