Yashwanth Ravula
Yashwanth Ravula

Reputation: 633

Emojis are not getting displayed in text received from api call, flutter

I am trying to display text which includes emojis from a string received in API response. The text is displaying properly but the emojis are getting displayed as some foreign characters. Please let me know how to fix this. Thanks.

Emojis in the text should be like this: 'So, how are you finding this app? 😄😅 Spare a min to rate it.'

But it is getting displayed as below.

Screen shot of emulator

Upvotes: 6

Views: 1541

Answers (2)

Sharath B Naik
Sharath B Naik

Reputation: 1362

Try this

final response = http.get(Uri.parse("https://example.com/chats"));
final decodedResponse = json.decode(utf8.decode(response.bodyBytes, allowMalformed: true));

If not worked, Check your database encoding. For Postgres run this command to know encoding

SHOW SERVER_ENCODING

Upvotes: -1

Nehil Koshiya
Nehil Koshiya

Reputation: 685

Pass your string in this method!

String utf8convert(String text) {
    List<int> bytes = text.toString().codeUnits;
    return utf8.decode(bytes);
  }

Upvotes: 11

Related Questions