core/model_management/model_specs library
Model specification value types — dart:io-free, shared across all
platforms (mobile, desktop, web).
These types used to be part of flutter_edge_ai_mobile.dart, which pulled
dart:io (and path_provider) into the public import graph and broke
dart2wasm compatibility (pub.dev "Platform support" WASM check). They are
extracted here as a standalone, platform-neutral library so the public API
surface and the platform interface can depend on the specs without dragging
in the mobile implementation's dart:io.
Classes
- DirectoryBundleFile
-
One file of a DIRECTORY inference model (ORT-GenAI): the model is a set of
files that must live together in a per-model subdirectory with their BARE
leaf names (
genai_config.jsonreferences its siblings by bare name and the native loader is handed the directory). filename is the EXPLICIT install identity<modelId>/<bareLeaf>(a real subpath) — NEVER derived from source, so the on-disk id and the repository key always agree (aFileSource-derived basename would drop the subdir and break the repo lookup on every restore). The PRIMARY file (genai_config.json) uses PreferencesKeys.installedModelFileName as its prefsKey so the persist-identity +modelFilePaths.values.firstboth find it; siblings use their bare leaf name so each maps to a distinctgetModelFilePathsentry. - DownloadProgress
- Progress information for model downloads
- EmbeddingModelFile
- Model file for embedding models (.bin files)
- EmbeddingModelSpec
- Specification for embedding models (model.bin + tokenizer.json)
- EmbeddingTokenizerFile
- Tokenizer file for embedding models (.json files)
- InferenceModelFile
- Model file for inference models (.bin, .task files)
- InferenceModelSpec
- Specification for inference models (main model + optional LoRA)
- LoraModelFile
- Model file for LoRA weights. A COMPANION of the inference model — its filename gets the modelId__ prefix so a LoRA adapter travels with the exact base model it was fine-tuned for (mirrors the tokenizer/aux namespacing used by embedding/STT/TTS companions).
- ModelFile
- Represents a single file that belongs to a model
- ModelSpec
- Base specification for any model (inference or embedding)
- OrphanedFileInfo
- Information about a potentially orphaned file
- StorageStats
- Storage statistics
- SttModelFile
- Model file for STT models (.tflite files)
- SttModelSpec
- Specification for STT models (model.tflite + tokenizer.json).
- SttTokenizerFile
- Tokenizer file for STT models (tokenizer.json)
- TtsAbsoluteUrl
- A full absolute URL fetched as-is — the install base URL is ignored.
- TtsAssetBase
- A Flutter asset directory, laid out like the model's Hugging Face repo.
- TtsBundleBase
-
Where a whole TTS bundle is installed from — the one base every manifest
file is resolved against by TtsModelTypeManifest.sourceFor. Internal: the
public surface is
TtsInstallationBuilder'sfromNetwork/fromAsset/fromFile/fromBundled. - TtsBundledBase
-
Native bundled resources, one per manifest file, named
<type>__<basename>(flat: a bundled resource name cannot contain/). - TtsBundleFile
-
One file of a TTS model bundle. filename is namespaced by the owning
TtsModelType (every bundle member — including the
.tflitegraphs — since a TTS bundle has no single distinguished "model" file the way Inference/Embedding/STT specs do). prefsKey stays the PLAIN manifest basename — NOT the namespaced filename — becauseflutter_edge_ai_speech'sTtsModelProfile(e.g.configFile = 'config.json') andTtsCore/MatchaTextFrontendlook bundle paths up by that plain name (paths[profile.configFile]); decoupling keeps that cross-package contract intact while the on-disk/repository identity is namespaced. - TtsFetchLocation
- Where one TTS bundle member is fetched from — the typed result of TtsModelTypeManifest.fetchLocationFor. Exactly two shapes exist: a TtsRelativeSuffix resolved against the model's install base URL, or a TtsAbsoluteUrl fetched as-is (a cross-repo file, e.g. Inflect's reused Matcha G2P bundle). TtsModelTypeManifest.sourceFor exhaustively switches on this, so the two cases can never be confused by string sniffing.
- TtsFileBase
- An absolute directory on disk, laid out like the model's Hugging Face repo.
- TtsModelSpec
- Specification for a TTS model — a SELECTABLE bundle. ttsModelType carries the model family so one generic backend dispatches to the right runtime profile; sources is one entry per file in that type's manifest.
- TtsNetworkBase
- A URL the bundle is served under, laid out like the model's Hugging Face repo.
- TtsRelativeSuffix
-
A relative path segment appended to the install base URL (the plain
basename itself, or a
tables//voices/subpath for qwen3's embedding-table/demo-voice members).
Enums
- ModelManagementType
- Base enumeration for different model management types
- ModelReplacePolicy
-
Policy for what happens to a previously-installed model when a new one is
set active. Lives with the spec value types (it's a per-spec install policy);
re-exported from
model_file_manager_interface.dartfor backward compat. - SttModelType
-
Speech-to-text model families supported by the pluggable STT backends.
Only moonshine has a shipped
SttModelProfile/pipeline (flutter_edge_ai_speech); the others are follow-ons that need a log-mel frontend. - TtsModelType
-
Text-to-speech model families supported by the pluggable TTS backends.
matcha, qwen3 and inflect have shipped
TtsModelProfile/pipelines (flutter_edge_ai_speech); kokoro/supertonic are documented follow-ons (fail-loud until wired).
Extensions
- TtsModelTypeManifest on TtsModelType
- The filenames a given TTS model needs, installed together as a bundle from one source. Fail-loud for unwired families.
Exceptions / Errors
- ModelDownloadException
- Exception thrown when model download fails
- ModelException
- Base exception for model management operations
- ModelStorageException
- Exception thrown when model storage operations fail
- ModelValidationException
- Exception thrown when model file validation fails