From bee61cb4fa3d44a6a88aeb3ddf56a4955546a914 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Tue, 6 Jul 2021 16:43:54 +0530 Subject: [PATCH] feat: added new docs --- .../stream_chat_flutter/message_widget.mdx | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/docusaurus/docs/Flutter/stream_chat_flutter/message_widget.mdx b/docusaurus/docs/Flutter/stream_chat_flutter/message_widget.mdx index 3f8e90ad..89a7cf0f 100644 --- a/docusaurus/docs/Flutter/stream_chat_flutter/message_widget.mdx +++ b/docusaurus/docs/Flutter/stream_chat_flutter/message_widget.mdx @@ -45,4 +45,52 @@ class ChannelPage extends StatelessWidget { ### Building A Custom Attachment When a custom attachment type (location, audio, etc.) is sent, the MessageWidget also needs to know -how to build it. \ No newline at end of file +how to build it. For this purpose, we can use the `customAttachmentBuilders` parameter. + +As an example, if a message has a attachment type 'location', we do: + +```dart +MessageWidget( + //... + customAttachmentBuilders: { + 'location': (context, message, attachments) { + var attachmentWidget = Image.network( + _buildMapAttachment( + attachments[0].extraData['latitude'], + attachments[0].extraData['longitude'], + ), + ); + + return wrapAttachmentWidget(context, attachmentWidget, null, true, BorderRadius.circular(8.0)); + } + }, +) +``` + +You can also override the builder for existing attachment types like `image` and `video`. + +### Show User Avatar For Messages + +You can decide to show, hide, or remove user avatars of the sender of the message. To do this, set +the `showUserAvatar` property like this: + +```dart +MessageWidget( + //... + showUserAvatar = DisplayWidget.show, +) +``` + +### Reverse the message + +In most cases, `MessageWidget` needs to be a different orientation depending upon if the sender is the +user or someone else. + +For this, we use the `reverse` parameter to change the orientation of the message: + +```dart +MessageWidget( + //... + reverse = true, +) +``` \ No newline at end of file