JsonAdapter<T> class
Adapter for objects that can be converted to and from JSON.
Allows storing complex objects by serializing them to JSON strings.
- Inheritance
-
- Object
- PrfAdapter<
T> - PrfEncodedAdapter<
T, String> - JsonAdapter
Constructors
-
JsonAdapter.new({required T fromJson(Map<
String, dynamic> json), required Map<String, dynamic> toJson(T object)}) - Creates a new JSON adapter with the specified conversion functions.
Properties
-
fromJson
→ T Function(Map<
String, dynamic> json) -
Function to convert from a JSON map to type
T
.final - hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
toJson
→ Map<
String, dynamic> Function(T object) -
Function to convert from type
T
to a JSON map.final
Methods
-
decode(
String? jsonString) → T? -
Decodes a value of storage type
TStore
back to typeT
.override -
encode(
T value) → String -
Encodes a value of type
T
to the storage typeTStore
.override -
getter(
SharedPreferencesAsync prefs, String key) → Future< T?> -
Retrieves a value of type
T
from SharedPreferences.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setter(
SharedPreferencesAsync prefs, String key, T value) → Future< void> -
Stores a value of type
T
in SharedPreferences.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited