JsonHelpers class
Reusable encoding/decoding helpers for JSON maps and method channel results.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
decode<
T> (dynamic value, [T fromJson(Map)?]) → T? - Decodes an optional value from JSON maps or method channel results.
-
decodeEnum<
T extends Enum> (dynamic value, List< T> values, [T? defaultValue]) → T - Decodes an enum from its name string.
-
decodeList<
T> (List? value, T fromJson(Map)) → List< T> - Decodes a list from JSON maps or method channel results, returning empty list if null.
-
encode<
T> (Map< String, dynamic> json, String key, T? value, [Map<String, dynamic> toJson(T)?]) → void - Encodes an optional value to a JSON map if not null.
-
encodeList<
T> (Map< String, dynamic> json, String key, List<T> list, Map<String, dynamic> toJson(T)) → void - Encodes a list to a JSON map if not empty.
-
formatToString(
String type, Map< String, Object?> fields) → String -
Builds a concise
toStringoutput from non-null fields.