tryJsonDecode static method
Returns a decoded Map from the JSON string value, optionally
cleaning the input first when shouldCleanInput is true, or null
if decoding fails.
Implementation
@useResult
static Map<String, dynamic>? tryJsonDecode(
String? value, {
bool shouldCleanInput = false,
}) {
if (value == null || value.isEmpty) return null;
if (shouldCleanInput) {
final String? cleaned = cleanJsonResponse(value);
if (cleaned == null || cleaned.isEmpty) return null;
return jsonDecodeToMap(cleaned);
}
return jsonDecodeToMap(value);
}