gemini_flutter 0.0.1+1 gemini_flutter: ^0.0.1+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_flutter
dependency to yourpubspec.yaml
file:dependencies: gemini_flutter: ^0.0.1+1
Then, run
flutter pub get
to fetch the dependency. -
In your Dart code, import the package:
import 'package:gemini_flutter/gemini_flutter.dart';
-
Initialize the
GeminiHandler
in yourmain
function:void main() { GeminiHandler().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().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");
}
}