emoji_utils 0.0.1
emoji_utils: ^0.0.1 copied to clipboard
A lightweight Dart utility for accurate single emoji detection. Handles ZWJ sequences, skin tone modifiers, variation selectors, flags, and all modern Unicode emoji ranges.
Emoji Utils #
A lightweight, pure Dart utility for detecting whether a string contains a single emoji. Correctly handles the full complexity of Unicode emoji sequences.
Features #
- ZWJ Sequences β Family (π¨βπ©βπ§βπ¦), profession, and combined emojis.
- Skin Tone Modifiers β Fitzpatrick scale support (ππ½).
- Variation Selectors β Handles both text and emoji presentation (β€οΈ vs β€).
- Flag Sequences β Regional indicator pairs (πΉπ·, πΊπΈ).
- Full Unicode 15.1 β All modern emoji ranges covered.
- Zero Dependencies β Pure Dart, no Flutter required.
Installation #
dependencies:
emoji_utils: ^<latest_version>
Usage #
import 'package:emoji_utils/emoji_utils.dart';
// Basic emojis
EmojiUtils.isSingleEmoji('π'); // true
EmojiUtils.isSingleEmoji('π'); // true
// Compound emojis
EmojiUtils.isSingleEmoji('π¨βπ©βπ§βπ¦'); // true (ZWJ family)
EmojiUtils.isSingleEmoji('ππ½'); // true (skin tone)
EmojiUtils.isSingleEmoji('πΉπ·'); // true (flag)
EmojiUtils.isSingleEmoji('β€οΈ'); // true (variation selector)
// Non-emoji strings
EmojiUtils.isSingleEmoji('Hello'); // false
EmojiUtils.isSingleEmoji('ππ'); // false (two emojis)
EmojiUtils.isSingleEmoji(''); // false
EmojiUtils.isSingleEmoji('abcπ'); // false (mixed)
Common Use Case: Chat Bubbles #
Display single emojis larger in chat messages, like iMessage or WhatsApp:
final message = 'β€οΈ';
if (EmojiUtils.isSingleEmoji(message)) {
// Render as a large standalone emoji (no bubble)
return Text(message, style: TextStyle(fontSize: 64));
} else {
// Render inside a normal chat bubble
return ChatBubble(child: Text(message));
}
License #
Licensed under the MIT License.