fromId static method

AnimatedEmojiData fromId(
  1. String id
)

Return the animated emoji that equals id.

When no emoji is found a EmojiNotFoundException is thrown.

// Will return a firework emoji 🎆
AnimatedEmojis.fromId('1f386')

Implementation

static AnimatedEmojiData fromId(String id) {
  try {
    // Allow legacy ids beginning with `u`.
    if (id[0] == 'u') {
      return AnimatedEmojis.values
          .firstWhere((element) => element.id == id.substring(1));
    }

    return AnimatedEmojis.values.firstWhere((element) => element.id == id);
  } catch (_) {
    throw EmojiNotFoundException.fromId(id);
  }
}