bubbleAvatarBuilder property

AssistWidgetBuilder? bubbleAvatarBuilder
final

A callback function creates a widget to display as an avatar within each message bubble.

The bubbleAvatarBuilder allows you to specify a custom widget that will be shown as an avatar within each message bubble. This is particularly useful for displaying user avatars or profile pictures in the chat interface.

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

@override
Widget build(BuildContext context) {
  return SfAIAssistView(
    bubbleAvatarBuilder:
        (BuildContext context, int index, AssistMessage message) {
      return CircleAvatar(
        backgroundImage: NetworkImage(
          message.author.id == '123-001'
              ? 'https://example.com/user-avatar.jpg'
              : 'https://example.com/ai-avatar.jpg',
        ),
      );
    },
  );
}

Implementation

final AssistWidgetBuilder? bubbleAvatarBuilder;