jsonDecodeSafe static method
Safely decodes a JSON string, returning null on error.
Implementation
static dynamic jsonDecodeSafe(String? jsonString) {
jsonString = jsonString?.trim();
if (jsonString == null || jsonString.isEmpty || jsonString == 'null') return null;
if (!isJson(jsonString)) return null;
try {
return dc.jsonDecode(jsonString);
} on FormatException {
return null;
}
}