applySkinTone method

Emoji applySkinTone(
  1. Emoji emoji,
  2. String color
)

///

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)
    ..addAll(codeUnits.sublist(0, min(codeUnits.length, 2)))
    ..addAll(color.codeUnits);
  if (codeUnits.length >= 2) {
    result.addAll(codeUnits.sublist(2));
  }
  return emoji.copyWith(emoji: String.fromCharCodes(result));
}