Code Monkey home page Code Monkey logo

flutter-emoji's Introduction

flutter_emoji

Build Status Coverage

Null Safety

๐Ÿ‘‰ A light-weight Emoji ๐Ÿ“ฆ for Flutter and Dart-based applications with all up-to-date emojis ๐Ÿ˜„. Made from ๐Ÿ’ฏ% โ˜• with โค๏ธ!

Inspired from the node-emoji package.

Update: since v2.3.4+, support all emojis listed in Unicode 13.0.

NOTE: I initially created this package to support my Flutter apps. However, Dart is growing to support on more platforms, so starting from v2.4.0+, this package will be available to all types of Dart-based applications.

Work in progress

I'm working on the new version of the package, it might or might not introduce breaking changes but I will try to maintain the compatibility in the API.

Here are few upcoming update to the v3:

  • Support Unicode 15.1+ emojis.
  • Skin tone
  • Group (category) of the emojis
  • Emoji version
  • Few new methods for handling/manipulating emojis.

Installation

Add this into pubspec.yaml

dependencies:
  flutter_emoji: ">= 2.0.0"

API Usage

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 and call its methods.

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:'

// Count number of present emojis
parser.count('I โค๏ธ Flutter just like โ˜•'); // returns: 2

// Count frequency of a specific emoji
parser.frequency('I โค๏ธ Flutter just like โ˜•', 'โค๏ธ'); // returns: 1

// Replace a specific emoji by another emoji
parser.replace('I โค๏ธ coffee', 'โค๏ธ', 'โค๏ธโ€๐Ÿ”ฅ'); // returns: 'I โค๏ธโ€๐Ÿ”ฅ coffee'

// Get a list of all emojis from the input
parser.parseEmojis('I โค๏ธ Flutter just like โ˜•'); // returns: ['โค๏ธ', 'โ˜•']

All methods will return Emoji.None if emoji is not found, except these two emojify() and unemojify() that will return original input.

parser.get('does_not_exist_emoji_name'); // returns: Emoji.None

Initialize emoji data for EmojiParser

There are two available datasets available you can choose to initialize for EmojiParser: local and server.

// to load local dataset
var localParser1 = EmojiParser();
var localParser2 = EmojiParser(init: false);
localParser2.initLocalData();

// to load server dataset
// this will trigger an URL request to download latest emoji data
var serverParser = EmojiParser(init: false);
await serverParser.initServerData(); // make sure to wrap in an `async` function/method.

NOTE: make sure to add Internet permission on Android.

<!-- Required to fetch data from the internet. -->
<uses-permission android:name="android.permission.INTERNET" />

In any occasion that local dataset doesn't have the latest emojis, load server dataset instead. If it is still not working, please create an issue or pull request to the repo.

TODO

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 additional formatting found emojis.
  • Ability to fetch latest emoji list.
  • Make extensible emoji matcher.

License

MIT @ 2019 Pete Houston.

flutter-emoji's People

Contributors

jibbers42 avatar luis901101 avatar petehouston avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter-emoji's Issues

How to use it description is not clear that's why it is not most popular and users are not able to use them in their project

How to use it description is not clear that's why it is not most popular and users are not able to use them in their project.

This is humble request to @petehouston Please update the package description and re-write it so that a new developer/user can use it easily. This is just friendly suggestion which will help you to make this package one of the most popular packages. Update example tab also on pub.dev. Example should be just like clone your repository and user can understand package feature in 10 seconds. Thanks a lot.

Can it detect a string is all emoji or not?

Hi Sir, thanks for this useful repo.

I wanna detect a string is all emoji or not, take an example:

๐Ÿ˜„๐Ÿ˜„ -> yes
๐Ÿ˜„ ff -> not

So how to achieve that using this repo? thanks in advance!

App crashes when I install the package

The flutter app crashes after I install flutter-emoji and import it above the current displayed view, each time I run hot-reload the app. It does the same when I use Emoji picker package. Is a problem with my flutter version?

`flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[โˆš] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [version 10.0.18362.592], locale en-EN)

[โˆš] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[โˆš] Android Studio (version 3.5)
[โˆš] IntelliJ IDEA Community Edition (version 2019.2)
[โˆš] IntelliJ IDEA Ultimate Edition (version 2019.2)
[โˆš] VS Code (version 1.39.2)
[โˆš] Connected device (1 available)

โ€ข No issues found!`

Substitute dash with underscore in JSON_EMOJI string

Hi, thanks for your work. I noticed that emoji with a tone (like "skin-tone-2" for example) can't be parsed because dashed don't get matched in your emojify method. I solved by replacing every dash with an underscore in the JSON_EMOJI string field.
Hope that helps!

Emoji memory performance

Hello, Im mainly using Emoji.byChar() and i saw in memory that i have 3500 instances of Emoji class.
Im using only map of 39 emojis.

Is this intended?

Emojifying a country

I followed your example and it works but when I use it to emojify a country it just shows the full text instead of the emoji.

ex:

EmojiParser().emojify('I :heart: :coffee:') // -> I โค๏ธ โ˜•
EmojiParser().emojify('I :flag-ca: :coffee:')  // -> I :flag-ca: โ˜•

and when I print the getEmoji/Name and hasEmoji/Name functions on it both the emoji and the name respectively I get the following:

I/flutter ( 7213): Emoji{name="flag-ca", full=":flag-ca:", code="๐Ÿ‡จ๐Ÿ‡ฆ"}
I/flutter ( 7213): Emoji{name="flag-ca", full=":flag-ca:", code="๐Ÿ‡จ๐Ÿ‡ฆ"}
true
true

When I use the emoji directly it works. What am I doing wrong?

update dependencies, http: ^1.0.0 is not supported

[yourapp] flutter pub get
Resolving dependencies...
Because flutter_emoji 2.4.0 depends on http ^0.13.4 and no versions of flutter_emoji match >2.4.0 <3.0.0, flutter_emoji ^2.4.0 requires http ^0.13.4.
So, because yourapp depends on both flutter_emoji ^2.4.0 and http ^1.0.0, version solving failed.

You can try the following suggestion to make the pubspec resolve:

  • Consider downgrading your constraint on http: flutter pub add http:^0.13.6
    exit code 1

Allow any replacement or deletion

Hi,

Thank you for your work, nice lib !
Could you please add the capabilities to remove all emojis (and/or) replace with any char/string ?

 EmojiParser().replaceAll("...", "X");
 EmojiParser().removeEmojis("..."); // which could be EmojiParser().replace("...", "");
 // Deletion/replacement to empty string should remove double space if any :) 

Thanks !

Wrong REGEX_NAME value

Currently the name regex is defined as follows

:([\w-]+):

Unluckily, this doesn't work with one of the most used emojis: ๐Ÿ‘
It's value is :+1: and the + is not contained inside the regex, which fails to pass and thus provide the valid emoji.

To solve this, the regex should be changed in

:([\w-+]+):

Adding the + would solve the problem.

Synchronize with node-emoji source

The node-emoji json source has archived into legacy branch. Considering with we need to change the source constant

from

static final String EMOJI_SOURCE =
      'https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json';

to

static final String EMOJI_SOURCE =
      'https://raw.githubusercontent.com/omnidan/node-emoji/legacy/lib/emoji.json';

Migrate to Sound Null Safety

Now that Flutter and Dart has stable support for Null Safety, it could be the right time to migrate this package to Null Safety.

How can you list all available emojis?

I'm trying to build an emoji picker but seems like this package does not have a way in which you can retrieve all emojis or emojis based on categories like other packages.
Is there a way to retrieve all emojis and also emojis based on category like you have in most apps that use emoji?

Emoji Regex

I was wondering if you could help me with blocking emojis from being typed into input boxes.

The emoji ๐ŸŒฌ๏ธ (and a few others) still get typed into input boxes that have been blacklisted with your regex.

   return BlacklistingTextInputFormatter(
        EmojiParser.REGEX_EMOJI
    );

They dont get typed but they get counted as input. E.g. if you have a hint in the text box (or character count) and type the emoji the hint will disappear and the character count will increase to 1. There is actually no input in the box, just empty space.

JSON_EMOJI not complete

Hi,

When I tried to use hasEmoji with ๐Ÿฅฐ, it returns false because it can't be found in _emojisByCode.
I search in JSON_EMOJI and "smiling face with hearts" is not in the string.

Is there any way to add missing emojis?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.