flutter_chatview icon indicating copy to clipboard operation
flutter_chatview copied to clipboard

Animate Text like in chatbots

Open Princewil opened this issue 1 year ago • 2 comments

It is possible to animate the text like in a chatbot?

Princewil avatar Jan 30 '25 17:01 Princewil

I just added this feature. I sent a PR @ this

Princewil avatar Jan 31 '25 18:01 Princewil

Hi @Princewil Thankyou for your time and input to improve the package, but please read the below comment to acheive the output without changing the package code. Thankyou.

Animated Chatbot Text Using customMessageBuilder

chatview already exposes customMessageBuilder, which is explicitly designed to let consumers render any widget they want for a message. Since animated chatbot text is purely a UI concern, it fits perfectly into MessageType.custom.

Because of this, there is no need to add a dependency on animated_text_kit (or any animation package) inside chatview itself. Users can implement animations entirely on their side using the existing API.


How to Do It with the Existing API

1. Add a Custom Message

_chatController.addMessage(
  Message(
    id: DateTime.now().toString(),
    createdAt: DateTime.now(),
    message: message,
    sentBy: _chatController.currentUser.id,
    messageType: MessageType.custom,
  ),
);

2. Render it using customMessageBuilder:

customMessageBuilder: (message) {
  return AnimatedTextKit(
    animatedTexts: [
      TypewriterAnimatedText(
        message.message,
      ),
    ],
  );
},

Please view the working code in gist - https://gist.github.com/japanshah-simform/e2d4746929d12ca00d082e4f9a2b1bc2

Preview

https://github.com/user-attachments/assets/6a200d4c-1347-42ef-bf77-f25765cc8f67

japanshah-simform avatar Dec 19 '25 10:12 japanshah-simform

please view the explanation above to use customMessageBuilder to Animate text like Chatbot.

japanshah-simform avatar Jan 09 '26 12:01 japanshah-simform