emojify method
Emojify the input text.
For example: 'I :heart: :coffee:' => 'I ❤️ ☕'
Implementation
String emojify(String text, {String Function(String)? fnFormat}) {
Iterable<Match> matches = REGEX_NAME.allMatches(text);
if (matches.isNotEmpty) {
var result = text;
for (Match m in matches) {
var _e = EmojiUtil.stripColons(m.group(0));
if (_e == null || m.group(0) == null) continue;
if (hasName(_e)) {
var pattern = RegExp.escape(m.group(0)!);
var formattedCode = get(_e).code;
if (fnFormat != null) {
formattedCode = fnFormat(formattedCode);
}
result =
result.replaceAll(RegExp(pattern, unicode: true), formattedCode);
}
}
return result;
}
return text;
}