Flutter – different chatBubble colors for sender and reciever


if we want to know the difference between the sender and receiver, each one of them should have a color, for example : senders bubble should be green and receiver’s should be white, how can we implement such a thing?


First, use the package chat_bubble https://pub.dev/packages/chat_bubble

      shadows: <Shadow>[
          color: Colors.grey,
          offset: Offset(-1.0, -1.0),
          blurRadius: 0.1,
          color: Colors.grey,
          offset: Offset(1.0, 1.0),
          blurRadius: 0.4,
      direction: reverse ? ChatBubbleNipDirection.RIGHT:  ChatBubbleNipDirection.LEFT,
      child: Container(
        color: isReceiver ? Colors.white : Colors.green,
        child: img,

where isReceiver is a bool variable that denotes whether it is a receiver or sender.

Answered By – Roslan Amir

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published