I am trying to create a news report app from a Wordpress site using REST API but it is encoded in UTF-8.
I am new in Dart, all I know is that I can decode Utf-8 just by an array of characters not by giving a string (as an input). Then how can I decode a string in Utf-8 for my app?
child: new Text(posts[index]["title"]['rendered'],
style: TextStyle(
fontSize: 21,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center),
),
new Padding(
padding: EdgeInsets.all(10.0),
child: new ListTile(
subtitle: new Text(posts[index]["excerpt"]
["rendered"]
.replaceAll(new RegExp(r'<[^>]*>'), '')),
),
),
Here is a picture of the result: https://imgur.com/gallery/qxkc9yP
You can get the body bytes and convert it..
http.Response response = await _api.getData();
String source = Utf8Decoder().convert(response.bodyBytes);
// Convert to your class instance...
MyClass instance = json.decode(source);
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