initialize static method
Initialize Flutter Gemma
Call this once at app startup before using any other API.
Parameters:
huggingFaceToken: Optional HuggingFace API token for authenticated downloadsmaxDownloadRetries: Maximum retry attempts for transient errors (default: 10) Note: Auth errors (401/403/404) always fail after 1 attemptenableWebCache: Enable persistent caching on web platform (default: true) Note: This parameter only affects web platform, ignored on mobile
Example:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterGemma.initialize();
runApp(MyApp());
}
Implementation
static Future<void> initialize({
String? huggingFaceToken,
int maxDownloadRetries = 10,
bool enableWebCache = true,
}) async {
ServiceRegistry.initialize(
huggingFaceToken: huggingFaceToken,
maxDownloadRetries: maxDownloadRetries,
enableWebCache: enableWebCache,
);
}