persist method
PersistResult
persist(
- FutureOr<
Storage< storage, {String, String> > - String? key,
- String encode(
- Profile state
- Profile 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(Profile state)? encode,
Profile 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 Profile.fromJson(e as Map<String, Object?>);
},
options: options,
);
}