bubbleContentBuilder property
A callback function creates a widget to display as the content of each chat bubble.
The bubbleContentBuilder allows you to specify a custom widget to display as the content within each chat bubble. This is useful for customizing how the message content is presented, such as using different background colors, borders, or padding.
The callback accepts three parameters: BuildContext, message index in the list, and ChatMessage and returns a Widget.
If a new instance is not assigned to this property, it will use the default content widget.
@override
Widget build(BuildContext context) {
return SfChat(
bubbleContentBuilder:
(BuildContext context, int index, ChatMessage message) {
return Padding(
padding: EdgeInsets.all(8.0),
child: Text(message.text),
);
},
);
}
See also
- The
contentPadding
in ChatBubbleSettings for adjusting the padding around bubble's content of the bubbleContentBuilder.
Implementation
final ChatWidgetBuilder? bubbleContentBuilder;