I am working on a Flutter chat app where I want to detect if a string contains 1 or more emojis so that I can make the font size of that text larger (Similar to iMessage or Messages).
When i say emojis, I mean basically any standard Unicode character you can find here.
CodePudding user response:
Using the package flutter_emoji you can parse your string from emoji to text and if your trying to check if your string only contains emoji's or if it also had plain text you can use
bool isAllEmoji(String text) {
for (String s in EmojiParser().unemojify(text).split(" ")) if (!s.startsWith(":") || !s.endsWith(":")) return false;
return true;
}
which will return true or false based on if it contains plain text or not
CodePudding user response:
Based on this, i was able to find emojis using:
void main() {
String str = "this ⛵️ is some text with