MobileModelManager class

Main unified model manager that orchestrates all model operations

Inheritance

Constructors

MobileModelManager()

Properties

activeEmbeddingModel → ModelSpec?
Gets the currently active embedding model specification
no setteroverride
activeInferenceModel → ModelSpec?
Gets the currently active inference model specification
no setteroverride
activeSttModel → ModelSpec?
Gets the currently active STT model specification
no setteroverride
activeTtsModel → ModelSpec?
Gets the currently active TTS model specification
no setteroverride
currentActiveModel → ModelSpec?
Gets the currently active model specification (backward compatibility)
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

cleanupStorage() → Future<int>
Clean up orphaned files
override
clearActiveEmbeddingIdentity() → Future<void>
Clears the active embedding identity (in-memory spec + persisted prefs).
override
clearActiveInferenceIdentity() → Future<void>
Clears the active inference identity (in-memory spec + persisted prefs).
override
clearActiveSttIdentity() → Future<void>
Clears the active STT identity (in-memory spec + persisted prefs).
override
clearActiveTtsIdentity() → Future<void>
Clears the active TTS identity (in-memory spec + persisted prefs).
override
clearModelCache() → Future<void>
Clears current model cache/state
override
deleteCurrentModel() → Future<void>
Legacy API: Deletes current active model (legacy method without parameters)
override
deleteLoraWeights() → Future<void>
Legacy API: Removes LoRA weights from current model
override
deleteModel(ModelSpec spec) → Future<void>
Deletes a model and all its files
override
downloadModel(ModelSpec spec, {String? token}) → Future<void>
Downloads a model without progress tracking
override
downloadModelWithProgress(ModelSpec spec, {String? token}) → Stream<DownloadProgress>
Downloads a model with progress tracking
override
ensureInitialized() → Future<void>
Ensures the manager is fully initialized — active model/embedder state restored from storage (#227). Idempotent and safe to call concurrently; all callers share a single initialization. Await this before reading activeInferenceModel / activeEmbeddingModel (#314).
override
ensureModelReady(String filename, String url) → Future<void>
Legacy API: Ensures a model is ready for use
override
ensureModelReadyFromSpec(ModelSpec spec) → Future<void>
Modern API: Ensures a model spec is ready for use
override
getInstalledModels(ModelManagementType type) → Future<List<String>>
Gets all installed models for a specific type
override
getModelFilePaths(ModelSpec spec) → Future<Map<String, String>?>
Gets the file paths for an installed model
override
getOrphanedFiles() → Future<List<OrphanedFileInfo>>
Get information about orphaned files
override
getStorageInfo() → Future<StorageStats>
Get storage statistics with orphaned file information
override
getStorageStats() → Future<Map<String, int>>
Gets storage statistics
override
initialize() → Future<void>
Initializes the unified model manager. Idempotent and concurrency-safe.
installModelFromAsset(String path, {String? loraPath}) → Future<void>
Legacy API: Installs model from Flutter assets (debug only)
override
installModelFromAssetWithProgress(String path, {String? loraPath}) → Stream<int>
Legacy API: Installs model from Flutter assets with progress tracking (debug only)
override
isAnyModelInstalled(ModelManagementType type) → Future<bool>
Checks if ANY model of the given type is installed
override
isModelInstalled(ModelSpec spec) → Future<bool>
Checks if a model is installed and valid
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performCleanup() → Future<void>
Performs cleanup of orphaned files
override
setActiveModel(ModelSpec spec) → void
Sets the active model for subsequent operations.
override
setLoraWeightsPath(String path) → Future<void>
Legacy API: Sets path to LoRA weights for current model
override
setModelPath(String path, {String? loraPath}) → Future<void>
Legacy API: Sets direct path to existing model files
override
toString() → String
A string representation of this object.
inherited
validateModel(ModelSpec spec) → Future<bool>
Validates all files for a model specification
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

createBundledEmbeddingSpec({required String modelResourceName, required String tokenizerResourceName, ModelReplacePolicy replacePolicy = ModelReplacePolicy.keep}) → EmbeddingModelSpec
Creates a bundled embedding model specification (for production builds)
createBundledInferenceSpec({required String resourceName, String? loraResourceName, ModelReplacePolicy replacePolicy = ModelReplacePolicy.replace, ModelType modelType = ModelType.general, ModelFileType fileType = ModelFileType.task}) → InferenceModelSpec
Creates a bundled inference model specification (for production builds)
createEmbeddingSpec({required String name, required String modelUrl, required String tokenizerUrl, ModelReplacePolicy replacePolicy = ModelReplacePolicy.keep}) → EmbeddingModelSpec
Creates an embedding model specification from parameters
createInferenceSpec({required String name, required String modelUrl, String? loraUrl, ModelReplacePolicy replacePolicy = ModelReplacePolicy.replace}) → InferenceModelSpec
Creates an inference model specification from parameters