count method

int count(
  1. String text
)

Count number of emoji containing in the text.

For example: count('I ❤️ Flutter just like ☕') = 2

Implementation

int count(String text) {
  if (text.isEmpty) return 0;

  int cnt = 0;
  for (final character in text.characters) {
    if (hasEmoji(character)) {
      cnt++;
    }
  }
  return cnt;
}