ModelManager class

Main entry point for model management operations.

Provides fine-grained control over OCR model lifecycle:

  • Download models separately from loading them
  • Pre-download during onboarding for offline-first UX
  • Query downloaded/loaded models with detailed metadata
  • Check for updates before downloading
  • Explicit memory management via load/unload

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cancelDownload(OCRModule module) Future<bool>
Cancels an active model download. Returns true if download was active and cancelled.
checkModelUpdates({required OCRModule module, String? apiKey, String? token, PlatformType platformType = PlatformType.flutter}) Future<ModelUpdateInfo>
Checks if a newer model version is available on the server.
deleteModel(OCRModule module) Future<bool>
Deletes a model from disk. Unloads from memory first if loaded. Returns true if model was downloaded and now deleted.
downloadModel({required OCRModule module, String? apiKey, String? token, PlatformType platformType = PlatformType.flutter, void onProgress(DownloadProgress)?}) Future<void>
Downloads a model from the server to disk.
findDownloadedModel(OCRModule module) Future<ModelInfo?>
Returns info for a specific downloaded model. Returns null if model is not downloaded.
findDownloadedModels() Future<List<ModelInfo>>
Returns all downloaded models by scanning the file system.
findLoadedModels() Future<List<ModelInfo>>
Returns all models currently loaded in memory.
isModelLoaded(OCRModule module) Future<bool>
Checks if a model is currently loaded in memory. O(1) operation.
loadedModelCount() Future<int>
Returns the number of models currently loaded in memory.
loadModel({required OCRModule module, String? apiKey, String? token, PlatformType platformType = PlatformType.flutter, ExecutionProvider executionProvider = ExecutionProvider.nnapi}) Future<void>
Loads a downloaded model into memory (ONNX Runtime).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
unloadModel(OCRModule module) Future<bool>
Unloads a model from memory. File remains on disk. Returns true if model was loaded and now unloaded.

Operators

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

Static Methods

create([void configure(ModelManagerConfigBuilder)?]) Future<ModelManager>
Creates a new ModelManager instance (not the singleton). Use this for custom configurations.
getInstance() ModelManager
Returns the initialized ModelManager singleton.
initialize([void configure(ModelManagerConfigBuilder)?]) Future<void>
Initializes the ModelManager singleton. Call once during app startup.
isInitialized() bool
Checks if the singleton has been initialized.