Here's my code: how I fetched data from the internet, using the package of HTTP and creating a model class
Future<Iterable<SubCategories>> fetchCategories() async {
final res = await http.post(
Uri.parse('https://___________________'),
);
final List<dynamic> responseJson = jsonDecode(res.body)["response"];
late Iterable<SubCategories> allCategories = responseJson
.map((subCategoryJson) => SubCategories.fromJson(subCategoryJson));
return allCategories;
}
All is well when Fetching English words, but Arabic words don't appear good I hope anyone can help me find how to read the Arabic text clearly as I can read the English text. Also, I tried to fix this issue by adding a Header but no results.
CodePudding user response:
Instead of jsonDecode(res.body)
, try jsonDecode(utf8.decode(res.bodyBytes))
Edit:
Now I saw more questions already here on SO.
Arabic letters not showing in Http response body - flutter
Invalid Arabic characters With Utf-8 charset Retrived with http.get Flutter