ModelStore class final
Verified models shared by every task family: the app's bundled copies, cached in the application's persistent support directory, and downloads when asked for. The same API in browsers, where models live in Cache Storage and a ModelSource holds bytes instead of a path.
Constructors
- ModelStore({String? cacheDirectory, String? source, Client? client})
-
cacheDirectoryreplaces application support (useful for tests and Dart command-line tools);sourceis a SHA-named local directory or internal URL root;clientreplaces the default HTTP client.
Properties
- cacheDirectory → String?
-
Override for the persistent root, primarily for tests.
final
- client → Client?
-
HTTP client override, primarily for tests.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → String?
-
A SHA-named local directory or internal URL root.
final
Methods
-
clear(
) → Future< void> - Removes every model this store holds, waiting for downloads in progress.
-
find(
DownloadAsset model) → Future< ModelSource?> -
The verified local copy of
model, without using the network: the cached file, else the app's bundled copy, which is copied into the cache once. Returns null when the app has neither. -
get(
DownloadAsset model) → Future< ModelSource> -
Returns the verified file for
model: cached, bundled or downloaded. Verifies every read and reuses valid bytes. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prefetch(
DownloadAsset model) → Future< void> - Prepares a model before task creation, for example on an onboarding page.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- allowDownloads ↔ bool
-
Whether tasks created with
model:may download a model the app does not bundle. Off by default:dart run mediapipe_core:bundle_modelsbundles models at build time instead. Set it before creating tasks.getter/setter pair -
debugBundledModels
↔ Future<
Uint8List?> Function(String sha256)? -
Stands in for the app's bundled models in tests.
getter/setter pair
- debugCacheDirectory ↔ String?
-
Stands in for application support when no cacheDirectory is given, in
tests that run without Flutter.
getter/setter pair