Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/GatchHQ/dart-emoji
A light-weight Emoji 📦 for Dart & Flutter with all up-to-date emojis written in pure Dart 😄 . Made from 💯% ☕ with ❤️!
https://github.com/GatchHQ/dart-emoji
dart dart-library dart-package emoji flutter null-safety
Last synced: 2 months ago
JSON representation
A light-weight Emoji 📦 for Dart & Flutter with all up-to-date emojis written in pure Dart 😄 . Made from 💯% ☕ with ❤️!
- Host: GitHub
- URL: https://github.com/GatchHQ/dart-emoji
- Owner: GatchHQ
- License: mit
- Created: 2021-11-21T14:18:52.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-24T13:13:38.000Z (6 months ago)
- Last Synced: 2024-08-01T12:25:08.306Z (5 months ago)
- Topics: dart, dart-library, dart-package, emoji, flutter, null-safety
- Language: Dart
- Homepage:
- Size: 85.9 KB
- Stars: 20
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# dart_emoji
👉 A light-weight Emoji 📦 for Dart & Flutter with all up-to-date emojis written in pure Dart 😄 . Made from 💯% ☕ with ❤️!
This is a fork of [flutter_emoji](https://pub.dev/packages/flutter_emoji), which is inspired by the [node-emoji](https://github.com/omnidan/node-emoji) package. The reason for the fork is better maintaining and adding further features, such as `EmojiUtil.hasOnlyEmojis()`.
`dart_emoji` is even used in production for our app Gatch. You can get Gatch for [iOS](https://gatch.fun/ios) and [Android](https://gatch.fun/android).
## API Usage
First, import the package:
```dart
import 'package:dart_emoji/dart_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`.
```dart
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:'// Check if text contains only emojis
EmojiUtil.hasOnlyEmojis("👋"); // returns true
EmojiUtil.hasOnlyEmojis("👋 Hello"); // returns false
```All methods will return `Emoji.None` if emoji is not found.
```dart
parser.get('does_not_exist_emoji_name'); // returns: Emoji.None
```## License
[MIT](LICENSE.md) @ 2021 [Gatch GmbH](https://gatch.fun).