bubbleHeaderBuilder property

AssistWidgetBuilder? bubbleHeaderBuilder
final

A callback function creates a widget to serve as a header for each message 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 AssistMessage 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 SfAIAssistView(
    bubbleHeaderBuilder:
        (BuildContext context, int index, AssistMessage message) {
      return Padding(
        padding: const EdgeInsets.all(8.0),
        child: Text(
          message.author.name,
          style: const TextStyle(fontWeight: FontWeight.bold),
        ),
      );
    },
  );
}

Implementation

final AssistWidgetBuilder? bubbleHeaderBuilder;