I am using Dio
for making the HTTP
request
var dio = Dio();
var response =
await dio.get(URL);
final responseBody = json.decode(response.data);
final statusCode = response.statusCode;
if (statusCode != 200 || responseBody == null) {
print("status code:$statusCode");
throw new ServerExceptionHandler(
"An error ocurred : [Status Code : $statusCode]", statusCode);
}
A response I am parsing
{
"x_id": "home"
}
but json.decode(response.data)
is throwing the exception.
type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'
The Strange thing is when I replace Dio
with http.get(url)
then json.decode(response.body)
works perfectly with same response