Ad

Unexpected Character (at Character 2) While Parsing Json Using Dio

- 1 answer

I was getting data from api using dio. It was successful but when data gets and it gets an exception.

Unexpected character (at character 2) {data:{id:5, name: ....

in error log, shows an arrow in beneath d(data)

What to do?

Ad

Answer

When I changed responsetype only for this API. It worked.

await dio.get(
    url, 
    options: Options(
        responseType: ResponseType.plain,
    ),

Ad
source: stackoverflow.com
Ad