gemini_flutter 0.0.1
gemini_flutter: ^0.0.1 copied to clipboard
A new Flutter package for easily using Gemini APIs in flutter projects
gemini_flutter #
A Flutter package to simplify the integration of Gemini APIs in your Flutter applications. Easily make calls to Gemini APIs by initializing the GeminiHandler and utilizing the provided functions.
Getting Started #
To use this package, follow the steps below:
-
Add the
gemini_flutterdependency to yourpubspec.yamlfile:dependencies: gemini_flutter: ^1.0.0Then, run
flutter pub getto fetch the dependency. -
In your Dart code, import the package:
import 'package:gemini_flutter/gemini_flutter.dart'; -
Initialize the
GeminiHandlerin yourmainfunction:void main() { GeminiHandler.instance.initialize( apiKey: "YOUR_API_KEY", temperature: 0.7, topK: 50, topP: 0.8, outputLength: 100, ); runApp(MyApp()); }Make sure to replace
"YOUR_API_KEY"with your actual Gemini API key. You can also customize other parameters as needed.
Usage #
Text Generation #
TextOnlyResponseModel generateText(String prompt) {
try {
final response = GeminiHandler.instance.textOnly(prompt);
print("Generated Text: ${response.generatedText}");
return response;
} catch (e) {
print("Error: $e");
// Handle the error accordingly
return TextOnlyResponseModel(error: "Failed to generate text");
}
}