π A light-weight Emoji π¦ for Flutter with all up-to-date emojis π. Made from π―% β with β€οΈ!
Inspired from the node-emoji package.
Add this into pubspec.yaml
dependencies:
flutter_emoji: ">= 2.0.0"
First, import the package:
import 'package:flutter_emoji/flutter_emoji.dart';
There are two main classes you need to know to handle Emoji text: Emoji
and EmojiParser
.
Basically, you need to initialize an instance of EmojiParser
.
var parser = EmojiParser();
var coffee = Emoji('coffee', 'β');
var heart = Emoji('heart', 'β€οΈ');
// Get emoji info
var emojiHeart = parser.info('heart');
print(emojiHeart); '{name: heart, full: :heart:, code: β€οΈ}'
// Check emoji equality
heart == emojiHeart; // returns: true
heart == emojiCoffee; // returns: false
// Get emoji by name or code
parser.get('coffee'); // returns: Emoji{name="coffee", full=":coffee:", code="β"}
parser.get(':coffee:'); // returns: Emoji{name="coffee", full=":coffee:", code="β"}
parser.hasName('coffee'); // returns: true
parser.getName('coffee'); // returns: Emoji{name="coffee", full=":coffee:", code="β"}
parser.hasEmoji('β€οΈ'); // returns: true
parser.getEmoji('β€οΈ'); // returns: Emoji{name="heart", full=":heart:", code="β€οΈ"}
parser.emojify('I :heart: :coffee:'); // returns: 'I β€οΈ β'
parser.unemojify('I β€οΈ β'); // returns: 'I :heart: :coffee:'
All methods will return Emoji.None
if emoji is not found.
parser.get('does_not_exist_emoji_name'); // returns: Emoji.None
Features coming to this package:
- Get detail of an emoji.
- Refactor for easier usage.
- Validate bad input.
- Find list of available emojis from a given text.
- Replace emoji by another one.
- Callback for handling missing emojis on general methods.
- Auto-update emoji list.
- Make extensible emoji matcher.
MIT @ 2019 Pete Houston.