isOnlyEmoji property

bool isOnlyEmoji

Returns whether the string contains only emoji's or not.

Emojis guidelines 1 to 3 emojis: big size with no text bubble. 4+ emojis or emojis+text: standard size with text bubble.

Implementation

bool get isOnlyEmoji {
  final trimmedString = trim();
  if (trimmedString.isEmpty) return false;
  if (trimmedString.characters.length > 3) return false;
  final emojiRegex = RegExp(
    r'^(\u00a9|\u00ae|\u200d|[\ufe00-\ufe0f]|[\u2600-\u27FF]|[\u2300-\u2bFF]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])+$',
    multiLine: true,
    caseSensitive: false,
  );
  return emojiRegex.hasMatch(trimmedString);
}