stabilize static method

String stabilize(
  1. String emoji, {
  2. bool skin = true,
  3. bool gender = false,
})

stabilize skin and gender of emoji, if true.

Implementation

static String stabilize(String emoji, {bool skin = true, bool gender = false}){

  if (gender){
    emoji = emoji.replaceAll('\u{200D}\u{2642}\u{FE0F}', '') // remove ZWJ man from emoji
        .replaceAll('\u{200D}\u{2640}\u{FE0F}', '') // remove ZWJ woman from emoji
        .replaceAll('\u{1F468}', '\u{1F9D1}')  // replace man with person
        .replaceAll('\u{1F469}', '\u{1F9D1}') // replace woman with person
        .replaceAll('\u{1F474}', '\u{1F9D3}') // replace old man with old person
        .replaceAll('\u{1F475}', '\u{1F9D3}'); // replace old woman with old person
  }

  final emojiRunes = emoji.runes.toList();

  if (skin){
    emojiRunes.removeWhere((codeChar) => _isFitzpatrickCode(codeChar));
  }
  return String.fromCharCodes(emojiRunes);
}