FlutterGemma class
Modern API facade for Flutter Gemma
Provides clean, type-safe API for model management and inference.
Initialization
Initialize once at app startup:
void main() {
FlutterGemma.initialize(
huggingFaceToken: 'hf_...', // Optional: for gated models
maxDownloadRetries: 10, // Optional: default is 10
);
runApp(MyApp());
}
Install Models
// From network
final installation = await FlutterGemma.installModel()
.fromNetwork('https://huggingface.co/.../model.bin')
.withProgress((progress) => print('Progress: $progress%'))
.install();
// From asset
await FlutterGemma.installModel()
.fromAsset('models/gemma.bin')
.install();
// From bundled resource
await FlutterGemma.installModel()
.fromBundled('gemma.bin')
.install();
// From external file
await FlutterGemma.installModel()
.fromFile('/path/to/model.bin')
.install();
Load Models (Phase 5)
// TODO: Phase 5 - integrate with InferenceModel
// final model = await installation.loadForInference();
// final response = await model.generateResponse('Hello!');
Constructors
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
-
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
Static Methods
-
initialize(
{String? huggingFaceToken, int maxDownloadRetries = 10}) → void - Initialize Flutter Gemma
-
installEmbeddingModel(
) → EmbeddingInstallationBuilder - Start building an embedding model installation
-
installInferenceModel(
) → InferenceInstallationBuilder - Start building an inference model installation
-
installModel(
) → ModelInstallationBuilder - Start building a model installation (deprecated)
-
isModelInstalled(
String modelId) → Future< bool> - Check if a model is installed
-
listInstalledModels(
) → Future< List< String> > - List all installed models
-
reset(
) → void - Reset ServiceRegistry (primarily for testing)
-
uninstallModel(
String modelId) → Future< void> - Uninstall a model