# Message

## Send a message

```dart
Future<String?> sendTextEvent(String message,
      {String? txid,
      Event? inReplyTo,
      String? editEventId,
      bool parseMarkdown = true,
      bool parseCommands = true,
      String msgtype = MessageTypes.Text,
      String? threadRootEventId,
      String? threadLastEventId})
```

Input Parameters:

| Name              | Type   | Description       | Required |
| ----------------- | ------ | ----------------- | -------- |
| message           | String | message           | True     |
| txid              | String | txid              | False    |
| inReplyTo         | String | inReplyTo         | False    |
| threadRootEventId | String | threadRootEventId | False    |
| threadLastEventId | String | threadLastEventId | False    |

## Receive a message

```dart
late final Future<Timeline> _timelineFuture;
  final GlobalKey<AnimatedListState> _listKey = GlobalKey<AnimatedListState>();

  @override
  void initState() {
    _timelineFuture = widget.room.getTimeline(onChange: (i) {
      print('on change! $i');
      _listKey.currentState?.setState(() {});
    }, onInsert: (i) {
      print('on insert! $i');
      _listKey.currentState?.insertItem(i);
    }, onRemove: (i) {
      print('On remove $i');
      _listKey.currentState?.removeItem(i, (_, __) => const ListTile());
    }, onUpdate: () {
      print('On update');
    });
    super.initState();
  }
```

## Send live location message

```dart
sendLiveLocation(beaconInfoEventId: String, latitude: Double, longitude: Double, uncertainty: Double?): Cancelable
```

| Name              | Type   | Description                                     | Required |
| ----------------- | ------ | ----------------------------------------------- | -------- |
| beaconInfoEventId | String | event id of the initial beacon info state event | true     |
| latitude          | Double | latitude of the location                        | True     |
| longitude         | Double | longitude of the location                       | True     |
| uncertainty       | Double | Accuracy of the location in meters              | False    |

## Set Notification State

```dart
enum class RoomNotificationState {   
    ALL_MESSAGES_NOISY,
    ALL_MESSAGES,
    MENTIONS_ONLY,
    MUTE
}

suspend fun setRoomNotificationState(roomNotificationState: RoomNotificationState)
```

<table><thead><tr><th width="253">Name</th><th>Description</th></tr></thead><tbody><tr><td>ALL_MESSAGES_NOISY</td><td>All the messages will trigger a noisy notification.</td></tr><tr><td>ALL_MESSAGES</td><td>All the messages will trigger a notification.</td></tr><tr><td>MENTIONS_ONLY</td><td>Only the messages with user display name / user name will trigger notifications.</td></tr><tr><td>MUTE</td><td>No notifications.</td></tr></tbody></table>

## Send media message

```dart
fun sendMedia(
        attachment: ContentAttachmentData,
        compressBeforeSending: Boolean,
        roomIds: Set<String>,
        rootThreadEventId: String? = null,
        relatesTo: RelationDefaultContent? = null,
        additionalContent: Content? = null,
): Cancelable
```

| Name                  | Type   | Description                                                                                                | Required |
| --------------------- | ------ | ---------------------------------------------------------------------------------------------------------- | -------- |
| attachment            | String | the media to send                                                                                          | true     |
| compressBeforeSending | String | set to true to compress images before sending them                                                         | True     |
| roomIds               | String | set of roomIds to where the media will be sent. The current roomId will be add to this set if not present. | True     |
| rootThreadEventId     | String | when this param is not null, the Media will be sent in this specific thread                                | True     |
| relatesTo             | String | add a relation content to the media event                                                                  | True     |
| additionalContent     | String | additional content to put in the event content                                                             | True     |

**Output parameters**

`Cancelable`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sending-network.gitbook.io/sending.network/sdk-documentation/flutter-sdk/message.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
