setting<T> method
Creates a new Setting.
A single setting that exposes a type T to the consuming application.
The _key is a function that returns the key
for the setting. The _decode function is used to convert the raw value
from the underlying storage to the type T. The _encode function is
used to convert the value of type T to a raw value that can be stored
in the underlying storage.
Implementation
@protected
Setting<T> setting<T>({
required String key,
required Decoder<T> decode,
required Encoder<T> encode,
}) {
final s = Setting<T>(
settings: this,
key: key,
decode: decode,
encode: encode,
);
// Create a new `Map`, otherwise cache listeners won't be updated
_cache.value = Map.from(_cache.value..[key] = s);
return s;
}