hasOnlyEmojis static method

bool hasOnlyEmojis(
  1. String text, {
  2. bool ignoreWhitespace = false,
})

Returns true if the given text contains only emojis.

"👋" -> true "👋 Hello" -> false ":wave:" --> false "👋👋" -> true "👋 👋" -> false (if ignoreWhitespace is true, result is true)

Implementation

static bool hasOnlyEmojis(String text, {bool ignoreWhitespace = false}) {
  if (ignoreWhitespace) text = text.replaceAll(' ', '');
  for (final c in Characters(text))
    if (!REGEX_EMOJI.hasMatch(c)) return false;
  return true;
}