---
id: message_widget
sidebar_position: 11
title: MessageWidget
---

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.