Search code examples
flutterdartdio

Unexpected character (at character 2) while parsing json using dio


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?


Solution

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

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