Reading time: < 1 minute
When making a GET request using Flutter and the Dart programming language, I encountered an error while trying to display certain data. The encoding error occurs when receiving information with some characters, and when displaying them in the user interface, they are not shown correctly.
To fix the error shown in the above image, I add the following line of code when receiving the data in the GET request:
jsonDecode(utf8.decode(response.bodyBytes));
The code for the GET request would look as follows:
final response = await http.get(Uri.parse(uri), headers: headers); if (response.statusCode == 200) { setState(() { datosRecibidos = jsonDecode(utf8.decode(response.bodyBytes)); }); } else { }
Finally, in the following image, we can see the result with the encoding error resolved.
I hope this helps. Have a great day!!