abnormal
Unhandled Exception: FormatException: Unexpected character (at character 2)
Copy the code
Analysis of the
Flutter JSON reports the above error. Here IS the interface that requests login. Personal information is returned in the data of successful login, but null in the data of failure.
When this exception occurs, the returned data type is incorrectly defined,
In fact, this hole was buried by Dio, but there was no Dio in the error report.
To solve
Convert the obtained data stream to the Response type
options: Options(responseType: ResponseType.plain)
Copy the code
Map<String, dynamic> _responseMap = jsonDecode(response.data.toString());
Copy the code