Search code examples
dartflutter

How to detect emojis in a String in Flutter using Dart?


I want to take a String value, and find out if there are any emojis in it. Might be some regex magic but not sure how to do that.


Solution

  • Was looking for the same thing.

    Found this newly published package: https://pub.dartlang.org/packages/flutter_emoji

    MIT license.

    Looking at the source code it seems like this is the regex used:

    /// A tweak regexp to pass all Emoji Unicode 11.0
    /// TODO: improve this version, since it does not match the graphical bytes.
    static final RegExp REGEX_EMOJI = RegExp(r'(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])');
    

    I hope this information can be helpful.