I want to split a string of emojis into each emoji. so how can I do this in dart language?
void main() {
print('GoodJob'.split("")); // output: [G, o, o, d, J, o, b]
print('🤭🎱🏓'.split("")); // output: [�, �, �, �, �, �] but expected: ['🤭','🎱','🏓']
}
3
Answers
You can match all the emojis using regex, and then add them to a list:
Regex credit
Usage:
Docs from TextField recommends to use characters package to work with emoji in dart.
Docs describe as follows,
outputs
You can use the
runes
property ofString
.