WebModelManager class
Web Model Manager - Modern API Facade Pattern
Phase 5 Complete: This class now delegates all model management to the Modern API (ServiceRegistry + Handlers + Repository) instead of manually managing state. All methods are thin facades over the Modern API.
Architecture:
- OLD: Manual state maps (_installedModels, _modelPaths, etc.)
- NEW: Delegates to ServiceRegistry.instance → handlers → repository
Benefits:
- Single source of truth (repository)
- No code duplication
- Platform-agnostic (same pattern as MobileModelManager)
- Easier to maintain and test
- Inheritance
-
- Object
- ModelFileManager
- WebModelManager
Constructors
Properties
- activeEmbeddingModel → ModelSpec?
-
Gets the currently active embedding model specification
no setteroverride
- activeInferenceModel → ModelSpec?
-
Gets the currently active inference 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> -
Explicitly cleanup orphaned files (user must call this - NOT automatic)
Returns number of deleted files
override
-
clearModelCache(
) → Future< void> -
Clears model cache (legacy method)
override
-
deleteCurrentModel(
) → Future< void> -
Deletes current active model (legacy method without parameters)
override
-
deleteLoraWeights(
) → Future< void> -
Removes LoRA weights from current model
override
-
deleteModel(
ModelSpec spec) → Future< void> -
Deletes a model
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
-
ensureModelReady(
String filename, String url) → Future< void> -
Legacy API: Ensures a model is ready for use, handling all necessary operations
override
-
ensureModelReadyFromSpec(
ModelSpec spec) → Future< void> -
Modern API: Ensures a model spec is ready for use
override
-
getInstalledModels(
ModelManagementType type) → Future< List< String> > -
Gets list of installed model filenames
override
-
getModelFilePaths(
ModelSpec spec) → Future< Map< String, String> ?> -
Gets the file paths for an installed model
override
-
getOrphanedFiles(
) → Future< List< OrphanedFileInfo> > -
Gets list of orphaned files (files without active downloads)
override
-
getStorageInfo(
) → Future< StorageStats> -
Gets detailed storage information including orphaned files
override
-
getStorageStats(
) → Future< Map< String, int> > -
Gets storage statistics for installed models
override
-
initialize(
) → Future< void> - Initializes the web model manager
-
installModelFromAsset(
String path, {String? loraPath}) → Future< void> -
Installs model from Flutter asset (debug mode only)
override
-
installModelFromAssetWithProgress(
String path, {String? loraPath}) → Stream< int> -
Installs model from Flutter asset with progress (debug mode only)
override
-
isAnyModelInstalled(
ModelManagementType type) → Future< bool> -
Checks if any model is installed
override
-
isModelInstalled(
ModelSpec spec) → Future< bool> -
Checks if a model is installed
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 inference operations
override
-
setLoraWeightsPath(
String path) → Future< void> -
Sets path to LoRA weights for current model
override
-
setModelPath(
String path, {String? loraPath}) → Future< void> -
Sets model path for inference (web: URLs only)
override
-
toString(
) → String -
A string representation of this object.
inherited
-
validateModel(
ModelSpec spec) → Future< bool> -
Validates if a model is properly installed
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.keep}) → 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.keep}) → InferenceModelSpec - Creates an inference model specification from parameters