bubbleHeaderBuilder property

ChatWidgetBuilder? bubbleHeaderBuilder
final

A callback function creates a widget to serve as a header for each chat bubble.

The bubbleHeaderBuilder allows you to specify a custom widget that will be shown as a header within each chat bubble. This is particularly useful for displaying additional information such as the sender's name and timestamp associated with each message.

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 header widget.


@override
Widget build(BuildContext context) {
  return SfChat(
    bubbleHeaderBuilder:
      (BuildContext context, ChatMessage message) {
        return Padding(
          padding: EdgeInsets.all(8.0),
          child: Text(
            message.author.name,
            style: TextStyle(fontWeight: FontWeight.bold)
          ),
        );
      },
  );
}

See also:

  • The headerPadding in ChatBubbleSettings for adjusting the padding of the bubbleHeaderBuilder.

Implementation

final ChatWidgetBuilder? bubbleHeaderBuilder;