Home > Net >  Flutter - different chatBubble colors for sender and reciever
Flutter - different chatBubble colors for sender and reciever

Time:05-23

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?

CodePudding user response:

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

    ChatBubble(
      shadows: <Shadow>[
        Shadow(
          color: Colors.grey,
          offset: Offset(-1.0, -1.0),
          blurRadius: 0.1,
        ),
        Shadow(
          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.

  • Related