I have a backend built with Java and REST, and have this app in Android using Flutter, but there is an error when I am trying to display those characters.
for example instead of "Piña", the final work displays:

this is a part of the code where I am trying to use dart:convert, but not very succesful:
import 'dart:convert';
class ProductsProvider {
Future<List<Product>> loadProducts(
String urlMiddleware, Client client) async {
final url = '$urlMiddleware${Constants().getProducts}${client.code}';
final response = await http.get(url,
headers: <String, String>{'authorization': Constants().basicAuth});
print('Url');
print(url);
json.decode(utf8.decode(response.bodyBytes));
final List<Product> products = productFromJson(response.body).toList();
return products;
}
This is my model btw:
import 'dart:convert';
import 'package:pil_store/models/EnumValues.dart';
List<Product> productFromJson(String str) => List<Product>.from(json.decode(utf8.decode(str.runes.toList())).map((x) => Product.fromJson(x)));
String productToJson(List<Product> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
I am not so old with this Flutter technology, how can I display the right character?
I found the solution trying something different, just fyi:
class ProductsProvider {
Future<List<Product>> loadProducts(
String urlMiddleware, Client client) async {
final url = '$urlMiddleware${Constants().getProducts}${client.code}';
final response = await http.get(url,
headers: <String, String>{'authorization': Constants().basicAuth});
print('Url');
print(url);
final List<Product> products = productFromJson(Utf8Decoder().convert(response.bodyBytes)).toList();
return products;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With