outgoingUser property

String outgoingUser
final

The distinct identifier of the user who is sending the message.

This distinctive ID differentiates messages from the current user (outgoing message) from those sent by others (incoming message), ensuring an accurate display of the chat.

If ChatMessage.id is equal to outgoingUser, the message is considered an outgoing message; otherwise, it is considered an incoming message.

{@tool snippet}

List<ChatMessage> _messages = <ChatMessage>[
  ChatMessage(
    text: 'Hello, how can I help you today?',
    time: DateTime.now(),
    author: const ChatAuthor(
      id: 'a2c4-56h8-9x01-2a3d',
      name: 'Incoming user name',
    ),
  ),
  ChatMessage(
    text: 'I'm looking for help with the Flutter Chat widget.',
    time: DateTime.now(),
    author: const ChatAuthor(
      id: '8ob3-b720-g9s6-25s8',
      name: 'Outgoing user name',
    ),
  ),
];

@override
Widget build(BuildContext context) {
  return SfChat(
    outgoingUser: '8ob3-b720-g9s6-25s8',
  );
}

{@end-tool} See also:

Implementation

final String outgoingUser;