Chat: Enlarge font-size if message is only one emoji

Widgets & Design
Resolved

I've built something small I wanted to share with others. In messengers like Whatsapp and Signal, when a user sends a message that is only one emoji, the font-size will be increased. In FlutterFlow, I've built it as follows:

  1. I have added a custom function "isOneEmoji" that checks if a string consists of only one emoji, and returns a bool. It does that with a regex. (I don't know if the regex works 100% of the time but in my tests it worked well enough.)

bool isOneEmoji(String string) {
  /// MODIFY CODE ONLY BELOW THIS LINE

  final RegExp REGEX_EMOJI = RegExp(
      r'^(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])$');

  return REGEX_EMOJI.allMatches(string).isNotEmpty;

  /// MODIFY CODE ONLY ABOVE THIS LINE
}
  1. I then set the font size of the text widget to a conditional value; I call isOneEmoji with the message text and if it returns true, I set the font size to 24; otherwise to 14.

It's possible to modify this behaviour quite easily. For example, you could adjust the regular expression to check if it's 1 or 2 (or 3) emojis, and increase font size in all of those cases.

What have you tried so far?

See above

Did you check FlutterFlow's Documentation for this topic?
No
2