> 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/reference/dnotifier-class/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

Package: `dnotifier`

## Import

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

Workflow types are exported from the same package:

```dart
import 'package:dnotifier/dnotifier.dart'
    show DNotifier, Workflow, WorkflowContext, defineAgent, Agent, WorkflowError;
```

## Static method

| Method        | Signature                                                                                       | Returns | Description          |
| ------------- | ----------------------------------------------------------------------------------------------- | ------- | -------------------- |
| `defineAgent` | `defineAgent({ required String name, required AgentRun run, String? provider, String? model })` | `Agent` | Create a named agent |

## Instance methods

| Method                     | Signature                                                                                                                                                     | Returns                        | Transport        | Description                                |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ---------------- | ------------------------------------------ |
| `connect`                  | `connect()`                                                                                                                                                   | `Future<void>`                 | Both             | Authenticate; WebSocket handshake if `ws`  |
| `disconnect`               | `disconnect()`                                                                                                                                                | `void`                         | WS               | Close WebSocket, set `isConnected = false` |
| `getPlanLimits`            | `getPlanLimits()`                                                                                                                                             | `DNotifierPlanLimits?`         | Both             | Plan quotas from last auth                 |
| `send`                     | `send({ required String senderId, String? receiverId, List<String>? receiverIds, required dynamic data, bool saveHistory })`                                  | `Future<dynamic>`              | Both             | Send structured message                    |
| `sendBinary`               | `sendBinary({ required String senderId, required List<String> receiverIds, required List<int> buffer, String type })`                                         | `void`                         | WS only          | Send raw bytes                             |
| `sendAI`                   | `sendAI({ required String senderId, required dynamic message, bool saveHistory, String? sessionId, String? provider, String? model })`                        | `Future<dynamic>`              | Both             | AI prompt                                  |
| `fetchAIHistory`           | `fetchAIHistory({ required String senderId })`                                                                                                                | `Future<dynamic>`              | Both             | Fetch AI history                           |
| `deleteAIHistoryMessage`   | `deleteAIHistoryMessage({ required String senderId, required String messageId })`                                                                             | `Future<dynamic>`              | Both             | Delete AI history entry                    |
| `fetchChatHistory`         | `fetchChatHistory({ required String senderId, required List<String> receiverIds })`                                                                           | `Future<dynamic>`              | Both             | Request chat history                       |
| `deleteChatHistoryMessage` | `deleteChatHistoryMessage({ required String senderId, required String messageId })`                                                                           | `Future<dynamic>`              | Both             | Delete chat history entry                  |
| `search`                   | `search({ required String senderId, required String query, int? limit, double? minSimilarity, String? filterbySource })`                                      | `Future<dynamic>`              | Both             | Semantic search                            |
| `addDocument`              | `addDocument({ required String senderId, String? recordId, String? record_id, String? content, String? text, String? type, Map<String, dynamic>? metadata })` | `Future<dynamic>`              | Both             | Add RAG document                           |
| `updateDocument`           | `updateDocument({ ... })`                                                                                                                                     | `Future<dynamic>`              | Both             | Update RAG document                        |
| `deleteDocument`           | `deleteDocument({ required String senderId, String? recordId, String? record_id })`                                                                           | `Future<dynamic>`              | Both             | Delete RAG document                        |
| `listDocuments`            | `listDocuments({ required String senderId, int? limit, int? offset, String? type })`                                                                          | `Future<dynamic>`              | Both             | List documents                             |
| `getDocument`              | `getDocument({ required String senderId, String? recordId, String? record_id })`                                                                              | `Future<dynamic>`              | Both             | Get one document                           |
| `runWorkflow`              | `runWorkflow({ required Workflow workflow, required dynamic input, String? senderId })`                                                                       | `Future<WorkflowRunResult>`    | HTTP recommended | Run workflow                               |
| `runAgent`                 | `runAgent(Agent agent, { input, maxToolRounds?, observability?, ... })`                                                                                       | `Future<Map<String, dynamic>>` | HTTP recommended | Standalone tool-agent loop                 |

Also: `notifier.tools`, `notifier.mcp`. See [Tools & MCP — Dart](https://dnotifier.gitbook.io/product-docs/workflows-and-agents/tools-and-mcp/dart-flutter.md). | `sendWithOpenAI` | `sendWithOpenAI({ required String senderId, required dynamic message, String? openaiApiKey, String? model, String? baseUrl })` | `Future<dynamic>` | Both | **Deprecated** — calls `sendAI` |

## Instance fields

| Field              | Type      | Description          |
| ------------------ | --------- | -------------------- |
| `appId`            | `String`  | Application id       |
| `secret`           | `String`  | Application secret   |
| `transport`        | `String`  | `"ws"` or `"http"`   |
| `userId`           | `String`  | User id              |
| `url`              | `String`  | WebSocket URL        |
| `logs`             | `bool`    | Session logging flag |
| `isConnected`      | `bool`    | Connection state     |
| `aiEnabled`        | `bool`    | Plan AI flag         |
| `authToken`        | `String?` | Auth token           |
| `messageSizeLimit` | `int`     | Chunk size in bytes  |

## `DNotifierPlanLimits`

Returned by `getPlanLimits()`:

| Field                   | Type   |
| ----------------------- | ------ |
| `messagesHardLimit`     | `int?` |
| `maxAIRequestsPerMonth` | `int?` |
| `maxAIWordsPerMonth`    | `int?` |
| `knowledgeBaseMaxWords` | `int?` |
| `aiEnabled`             | `bool` |
| `maxUsers`              | `int?` |
| `maxRowsPerUser`        | `int?` |

## `WorkflowRunResult`

| Field         | Type                   | Description                        |
| ------------- | ---------------------- | ---------------------------------- |
| `result`      | `dynamic`              | Workflow `entry` return value      |
| `state`       | `Map<String, dynamic>` | Shared workflow state              |
| `executionId` | `String?`              | Present when observability enabled |

## Validation extras (Dart)

`search()` additionally validates:

* `limit` must be `> 0` when provided
* `minSimilarity` must be between `0` and `1` when provided

## Error types

| Error                         | When                                         |
| ----------------------------- | -------------------------------------------- |
| `StateError('Not connected')` | Method before `connect()`                    |
| `ArgumentError(...)`          | Missing/invalid parameters                   |
| `UnsupportedError`            | `send()` chunking over unsupported transport |
