model property

EmbeddingModel? get model

The cached embedder, or null when none is built — or when the one that was built has been closed.

Checked here as well as in reuseOrInvalidate because some callers read the model directly: every shell's initializedEmbeddingModel, and the web shell's RAG helpers. A model is closed the moment close() is called, but its listener only evicts it once the teardown has finished, so without this those readers were handed a model whose every call throws.

Implementation

EmbeddingModel? get model {
  final model = _cached?.model;
  return model == null || model.isClosed ? null : model;
}