WebStorageMode enum
Storage mode for web platform models
Controls how model files are stored and loaded on the web platform. Different modes are optimized for different model sizes and use cases.
Values
- cacheApi → const WebStorageMode
-
Cache API with Blob URLs (default) - for models <2GB
Uses browser Cache API for persistent storage. Models are downloaded as ArrayBuffer and converted to Blob URLs for MediaPipe.
Advantages:
- Fast model loading (cached in browser)
- Persistent across page reloads
- Works offline after initial download
Limitations:
- ArrayBuffer size limit (~2GB in most browsers)
- Not suitable for large models (E4B, 7B, 27B)
Use for: Gemma 2B, 3N models, most quantized models
- streaming → const WebStorageMode
-
OPFS with streaming - for models >2GB (E4B, 7B, 27B)
Uses Origin Private File System with ReadableStream to bypass ArrayBuffer memory limits. Models are streamed directly to OPFS and loaded via ReadableStreamDefaultReader.
Advantages:
- No memory limits (can handle 4GB+ models)
- Persistent across page reloads
- Memory-efficient streaming
Limitations:
- Requires modern browser with OPFS support
- Slightly slower initial load
Use for: Large models (E4B 4.2GB, Gemma 7B, etc.)
- none → const WebStorageMode
-
No caching (ephemeral) - model URLs stored in memory only
Blob URLs and metadata are stored in memory and cleared on hot restart or page reload. Models must be re-downloaded each time.
Advantages:
- No persistent storage
- Fast development iteration (hot restart cleans state)
Limitations:
- Models re-downloaded on each page reload
- Not suitable for production
Use for: Development, testing, privacy-sensitive scenarios
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
A numeric identifier for the enumerated value.
no setterinherited
- name → String
-
Available on Enum, provided by the EnumName extension
The name of the enum value.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
-
values
→ const List<
WebStorageMode> - A constant List of the values in this enum, in order of their declaration.