From c4a884bb25c4579f6249abe12093904fecc8830c Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Tue, 6 Jul 2021 16:19:45 +0530 Subject: [PATCH] feat: added new docs --- .../stream_chat_flutter/message_widget.mdx | 45 ++++++++++++++++++- 1 file changed, 44 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 eaafbb7e..3f8e90ad 100644 --- a/docusaurus/docs/Flutter/stream_chat_flutter/message_widget.mdx +++ b/docusaurus/docs/Flutter/stream_chat_flutter/message_widget.mdx @@ -2,4 +2,47 @@ id: message_widget sidebar_position: 11 title: MessageWidget ---- \ No newline at end of file +--- + +A Widget For Displaying Messages And Attachments + +### Background + +There are several things that need to be displayed with text in a message in a modern messaging app: +attachments, highlights if the message is pinned, user avatars of the sender, etc. + +To encapsulate all of this functionality into one widget, the Flutter SDK contains a `MessageWidget` +widget which provides these out of the box. + +### Basic Example (Modifying `MessageWidget` in `MessageListView`) + +Primarily, the `MessageWidget` is used in the `MessageListView`. To customize only a few properties +of the `MessageWidget` without supplying all other properties, the `messageBuilder` builder supplies +a default implementation of the widget for us to modify. + +```dart +class ChannelPage extends StatelessWidget { + const ChannelPage({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: MessageListView( + messageBuilder: (context, details, messageList, defaultMessageWidget) { + return defaultMessageWidget.copyWith( + showThreadReplyIndicator: false, + ); + }, + ), + + ); + } +} +``` + +### 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