installModelFromAssetWithProgress method
- @Deprecated('Use FlutterGemma.installInferenceModel().fromAsset().installWithProgress() instead')
- @override
override
Installs model from Flutter asset with progress (debug mode only)
⚠️ DEPRECATED: Use FlutterGemma.installInferenceModel().fromAsset().installWithProgress() instead
Migration:
// OLD:
await for (final progress in manager.installModelFromAssetWithProgress('assets/models/gemma.task')) {
print('Progress: $progress%');
}
// NEW:
await for (final progress in FlutterGemma.installInferenceModel()
.fromAsset('assets/models/gemma.task')
.installWithProgress()) {
print('Progress: ${progress.currentFileProgress}%');
}
Implementation
@Deprecated('Use FlutterGemma.installInferenceModel().fromAsset().installWithProgress() instead')
@override
Stream<int> installModelFromAssetWithProgress(String path, {String? loraPath}) async* {
if (kReleaseMode) {
throw UnsupportedError(
"Asset model loading is not supported in release builds. "
"Use fromNetwork() or fromBundled() instead."
);
}
await _ensureInitialized();
// Convert legacy parameters to Modern API ModelSpec
final spec = InferenceModelSpec(
name: FileNameUtils.getBaseName(path.split('/').last),
modelSource: ModelSource.asset(path),
loraSource: loraPath != null ? ModelSource.asset(loraPath) : null,
);
// Delegate to Modern API downloadModelWithProgress
// This provides real progress tracking from handlers
await for (final downloadProgress in downloadModelWithProgress(spec)) {
yield downloadProgress.currentFileProgress;
}
}