applySkinTone method
Applies skin tone to given emoji
Implementation
Emoji applySkinTone(Emoji emoji, String color) {
final codeUnits = emoji.emoji.codeUnits;
var result = List<int>.empty(growable: true)
// Basic emoji without gender (until char 2)
..addAll(codeUnits.sublist(0, min(codeUnits.length, 2)))
// Skin tone
..addAll(color.codeUnits);
// add the rest of the emoji (gender, etc.) again
if (codeUnits.length >= 2) {
result.addAll(codeUnits.sublist(2));
}
return emoji.copyWith(emoji: String.fromCharCodes(result));
}