modify static method

String modify(
  1. String emoji,
  2. fitzpatrick skinTone
)

Modify skin tone of emoji by requested skinTone

Implementation

static String modify(String emoji, fitzpatrick skinTone) {
  late int skinToneCharCode;
  switch(skinTone){
    case fitzpatrick.light:
      skinToneCharCode = 127995;
      break;
    case fitzpatrick.mediumLight:
      skinToneCharCode = 127996;
      break;
    case fitzpatrick.medium:
      skinToneCharCode = 127997;
      break;
    case fitzpatrick.mediumDark:
      skinToneCharCode = 127998;
      break;
    case fitzpatrick.dark:
      skinToneCharCode = 127999;
      break;
    case fitzpatrick.None:
      return stabilize(emoji);
  }

  final emojiRunes = emoji.runes.toList();
  final finalCharCodes = <int>[];
  for (final charCode in emojiRunes){
    if (!_isFitzpatrickCode(charCode)){
      finalCharCodes.add(charCode);
      if (_isModifiable(charCode)){
        finalCharCodes.add(skinToneCharCode);
      }
    }
  }
  return String.fromCharCodes(finalCharCodes);
}