watchEnum<T extends Enum> static method

PreferenceNotifier<T> watchEnum<T extends Enum>(
  1. Ref<Object?> ref,
  2. String key, {
  3. required T defaultValue,
  4. required List<T> values,
})

Preference notifier that starts with the current enum value for the given key, then emits a new value every time there are chanegs to the value associated with the given key.

Implementation

static PreferenceNotifier<T> watchEnum<T extends Enum>(
  Ref ref,
  String key, {
  required T defaultValue,
  required List<T> values,
}) {
  return SharedPreferenceNotifier._(
    ref,
    (sharedPref) => sharedPref.getCustomValue(
      key,
      defaultValue: defaultValue,
      adapter: EnumAdapter(values),
    ),
    defaultValue,
  );
}