addDocument method

Future<SourceAddResult> addDocument(
  1. String content, {
  2. String? metadata,
  3. String? name,
  4. String? filePath,
  5. ChunkingStrategy? strategy,
  6. Duration? chunkDelay,
  7. void onProgress(
    1. int done,
    2. int total
    )?,
})

Add a document with automatic chunking and embedding.

The document is split into chunks, embedded, and stored.

Note: Indexing is automatic (debounced by 500ms). You generally do NOT need to call rebuildIndex manually, unless you want to ensure the index is ready immediately (e.g., before a UI update).

Implementation

Future<SourceAddResult> addDocument(
  String content, {
  String? metadata,
  String? name,
  String? filePath,
  ChunkingStrategy? strategy,
  Duration? chunkDelay,
  void Function(int done, int total)? onProgress,
}) => _engine!.addDocument(
  content,
  metadata: metadata,
  name: name,
  filePath: filePath,
  strategy: strategy,
  chunkDelay: chunkDelay,
  onProgress: onProgress,
);