isHtmlOrTextResponse method
Returns true if the response body appears to be HTML or plain text (not JSON).
Implementation
@override
bool isHtmlOrTextResponse(String responseBody) {
final t = responseBody.trim();
if (t.startsWith('<!DOCTYPE html>') ||
t.startsWith('<html') ||
(t.contains('<head>') && t.contains('<body>'))) {
return true;
}
if (t.isEmpty) {
return false;
}
if (t.length < 5 && !t.startsWith('{') && !t.startsWith('[')) {
return true;
}
return false;
}