instance property
ServiceRegistry
get
instance
Gets the singleton instance
Throws StateError if not initialized.
Must call FlutterGemma.initialize() first in main():
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await FlutterGemma.initialize();
runApp(MyApp());
}
Implementation
static ServiceRegistry get instance {
if (_instance == null) {
throw StateError(
'FlutterGemma not initialized!\n\n'
'You must call FlutterGemma.initialize() in main() before using the plugin.\n\n'
'Example:\n'
' void main() async {\n'
' WidgetsFlutterBinding.ensureInitialized();\n'
' await FlutterGemma.initialize();\n'
' runApp(MyApp());\n'
' }\n\n'
'For more information, see: https://pub.flutter-io.cn/packages/flutter_gemma#initialization'
);
}
return _instance!;
}