> 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/ai/manage-documents/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

Full CRUD for the DNotifier knowledge base over HTTP.

## Setup

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

const userId = 'indexer-service';

Future<DNotifier> createNotifier() async {
  final notifier = DNotifier(
    appId: 'your-app-id',
    secret: 'your-app-secret',
    transport: 'http',
    userId: userId,
    onConnected: () {},
    onMessage: (_) {},
  );
  await notifier.connect();
  return notifier;
}
```

## Add

```dart
await notifier.addDocument(
  senderId: userId,
  recordId: 'refund-policy',
  content:
      'Refund requests are processed within 5 business days after approval.',
  type: 'text',
  metadata: {'source': 'help-center', 'locale': 'en'},
);
```

## Update

```dart
await notifier.updateDocument(
  senderId: userId,
  recordId: 'refund-policy',
  content:
      'Refund requests are processed within 3 business days after approval.',
  type: 'text',
  metadata: {'source': 'help-center', 'locale': 'en', 'version': 2},
);
```

## Get one document

```dart
final doc = await notifier.getDocument(
  senderId: userId,
  recordId: 'refund-policy',
);
print(doc);
```

## List (paginated)

```dart
final list = await notifier.listDocuments(
  senderId: userId,
  limit: 20,
  offset: 0,
  type: 'text',
);
print(list);
```

## Delete

```dart
await notifier.deleteDocument(
  senderId: userId,
  recordId: 'refund-policy',
);
```

## Batch import

```dart
final articles = [
  {'id': 'faq-password', 'content': 'Reset password from Settings → Security.'},
  {'id': 'faq-billing', 'content': 'Invoices are emailed on the 1st of each month.'},
];

for (final article in articles) {
  await notifier.addDocument(
    senderId: userId,
    recordId: article['id']!,
    content: article['content']!,
    type: 'faq',
    metadata: {'source': 'help-center'},
  );
  print('Indexed: ${article['id']}');
}
```

## Learn more

* [**Semantic search**](https://dnotifier.gitbook.io/product-docs/ai/semantic-search/dart-flutter.md)
* [**Example: RAG bot**](https://dnotifier.gitbook.io/product-docs/ai/example-rag-bot/dart-flutter.md)
