> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/realtime-communication/multiple-receivers/dart-flutter.md). Agents can also search and read this documentation through its [MCP server](https://dnotifier.gitbook.io/product-docs/~gitbook/mcp).

# Dart / Flutter

Send one payload to several recipients with `receiverIds`.

***

## Basic example

```dart
import 'package:dnotifier/dnotifier.dart';

Future<void> main() async {
  final notifier = DNotifier(
    appId: 'your-app-id',
    secret: 'your-app-secret',
    transport: 'ws',
    userId: 'user-alice',
    onConnected: () {},
    onMessage: (msg) => print(msg.payload.toJSON()),
  );

  await notifier.connect();

  await notifier.send(
    senderId: 'user-alice',
    receiverIds: ['user-bob', 'user-carol', 'user-dave'],
    data: {
      'type': 'text',
      'text': 'Hello everyone',
    },
  );
}
```

***

## Team notification pattern

```dart
const teamMemberIds = ['employee-101', 'employee-102', 'employee-103'];

await notifier.send(
  senderId: 'svc-notifications',
  receiverIds: teamMemberIds,
  data: {
    'type': 'notification',
    'title': 'Deploy complete',
    'body': 'v2.4.0 is live in production.',
  },
  saveHistory: false,
);
```

***

## Dynamic member list

```dart
Future<void> broadcastToRoom(String roomId, Map<String, dynamic> payload) async {
  final members = await loadRoomMembersFromYourDb(roomId);
  final receiverIds = members.map((m) => m.userId).toList();

  await notifier.send(
    senderId: currentUserId,
    receiverIds: receiverIds,
    data: payload,
  );
}
```

Your app owns room membership, moderation, and access control.

***

## `sendBinary` with multiple receivers

```dart
notifier.sendBinary(
  senderId: 'user-alice',
  receiverIds: ['user-bob', 'user-carol'],
  buffer: [0x00, 0x01, 0x02],
);
```

***

## Troubleshooting

| Issue                                               | Check                                                |
| --------------------------------------------------- | ---------------------------------------------------- |
| Only some recipients receive                        | Offline users won't get live delivery                |
| `ArgumentError: receiverId or receiverIds required` | Pass non-empty `receiverIds`                         |
| Wrong recipients                                    | Verify member list matches DNotifier `userId` values |

***

## Learn more

* [Send & receive text](https://dnotifier.gitbook.io/product-docs/realtime-communication/send-and-receive/dart-flutter.md)
* [Binary messaging](https://dnotifier.gitbook.io/product-docs/realtime-communication/binary-messaging/dart-flutter.md)
