persist method
PersistResult
persist(
- FutureOr<
Storage< storage, {String, String> > - String? key,
- String encode(
- Settings state
- Settings decode(
- String encoded
- StorageOptions options = const StorageOptions(),
inherited
A variant of persist
, for JSON-specific encoding.
You can override key
to customize the key used for storage.
Implementation
PersistResult persist(
FutureOr<Storage<String, String>> storage, {
String? key,
String Function(Settings state)? encode,
Settings Function(String encoded)? decode,
StorageOptions options = const StorageOptions(),
}) {
return NotifierPersistX(this).persist<String, String>(
storage,
key: key ?? this.key,
encode: encode ?? $jsonCodex.encode,
decode: decode ??
(encoded) {
final e = $jsonCodex.decode(encoded);
return Settings.fromJson(e as Map<String, Object?>);
},
options: options,
);
}