value<T> static method

Future<Prf<T>> value<T>(
  1. String key, {
  2. T? defaultValue,
})

Creates a new pre-cached preference object.

This factory method creates a new Prf instance and immediately loads its value into the cache for faster subsequent access. This is not isolate-safe.

  • key is the key to store the preference under.
  • defaultValue is the value to use if no value exists for the key.

Implementation

static Future<Prf<T>> value<T>(
  String key, {
  T? defaultValue,
}) async {
  final object = Prf<T>(key, defaultValue: defaultValue);
  await object.initCache(PrfService.instance);
  return object;
}