JsonCare class
A tolerant JSON parsing helper designed to prevent runtime crashes caused by unexpected API type mismatches.
JsonCare provides static methods that safely cast or parse dynamic values into specific Dart types. If a value is null or cannot be parsed, it returns a sensible default value.
Constructors
- JsonCare()
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
-
boolVal(
dynamic v, {bool def = false}) → bool -
Safely converts a dynamic value
vto bool. -
dateVal(
dynamic v, {DateTime? def}) → DateTime -
Safely converts a dynamic value
vto DateTime (Local Time). -
doubleVal(
dynamic v, {double def = 0.0}) → double -
Safely converts a dynamic value
vto double. -
enumValue<
T> (dynamic v, List< T> values, {required T def}) → T -
Safely converts a dynamic value
vto an Enum value from the providedvalueslist. -
intVal(
dynamic v, {int def = 0}) → int -
Safely converts a dynamic value
vto int. -
list<
T> (dynamic v, T mapper(dynamic)) → List< T> -
Safely parses a dynamic value
vas a List of items using amapperfunction. -
map(
dynamic v) → Map< String, dynamic> -
Safely returns a dynamic value
vas a Map<String, dynamic>. -
string(
dynamic v, {String def = ""}) → String -
Safely converts a dynamic value
vto String.