> 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/semantic-search/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

Query the knowledge base with **vector similarity** over HTTP.

## Basic search

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

const userId = 'user-123';

Future<void> main() async {
  final notifier = DNotifier(
    appId: 'your-app-id',
    secret: 'your-app-secret',
    transport: 'http',
    userId: userId,
    onConnected: () {},
    onMessage: (_) {},
  );

  await notifier.connect();

  final hits = await notifier.search(
    senderId: userId,
    query: 'how long do refunds take',
    limit: 5,
    minSimilarity: 0.7,
    filterbySource: 'help-center',
  );

  print(hits);
}
```

## Search then answer manually

```dart
Future<String> answerWithSearch(
  DNotifier notifier,
  String userQuestion,
) async {
  final hits = await notifier.search(
    senderId: userId,
    query: userQuestion,
    limit: 3,
    minSimilarity: 0.5,
  );

  final context = hits.toString();

  final response = await notifier.sendAI(
    senderId: userId,
    message: {
      'messages': [
        {
          'role': 'system',
          'content': 'Answer using only this context:\n$context',
        },
        {'role': 'user', 'content': userQuestion},
      ],
    },
    saveHistory: true,
  );

  if (response is Map && response['data'] is Map) {
    return response['data']['content']?.toString() ?? '';
  }
  return response.toString();
}
```

## Workflow context

```dart
final hits = await ctx.search(
  query: 'refund policy',
  limit: 10,
  minSimilarity: 0.3,
  filterbySource: 'help-center',
  label: 'FAQ search',
);
```

## Learn more

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