findEmojiKeyListFromText static method
Implementation
static List<String> findEmojiKeyListFromText(String text) {
if (text == null || text.isEmpty) {
return [];
}
List<String> emojiKeyList = [];
// TUIKit custom emoji.
String regexOfCustomEmoji = "\\[(\\S+?)\\]";
Pattern patternOfCustomEmoji = RegExp(regexOfCustomEmoji);
Iterable<Match> matcherOfCustomEmoji = patternOfCustomEmoji.allMatches(text);
for (Match match in matcherOfCustomEmoji) {
String? emojiName = match.group(0);
if (emojiName != null && emojiName.isNotEmpty) {
emojiKeyList.add(emojiName);
}
}
// Universal standard emoji.
String regexOfUniversalEmoji = getRegexOfUniversalEmoji();
Pattern patternOfUniversalEmoji = RegExp(regexOfUniversalEmoji);
Iterable<Match> matcherOfUniversalEmoji = patternOfUniversalEmoji.allMatches(text);
for (Match match in matcherOfUniversalEmoji) {
String? emojiKey = match.group(0);
if (text.isNotEmpty && emojiKey != null && emojiKey.isNotEmpty) {
emojiKeyList.add(emojiKey);
}
}
return emojiKeyList;
}