google_mlkit_genai_prompt 0.1.0 copy "google_mlkit_genai_prompt: ^0.1.0" to clipboard
google_mlkit_genai_prompt: ^0.1.0 copied to clipboard

A Flutter plugin to use Google's ML Kit GenAI Prompt API to send custom requests to Gemini Nano.

Google's ML Kit GenAI Prompt for Flutter #

Pub Version analysis Star on Github License: MIT

A Flutter plugin to use Google's ML Kit GenAI Prompt API to generate text content based on custom prompts.

PLEASE READ THIS before continuing or posting a new issue:

  • Google's ML Kit was build only for mobile platforms: iOS and Android apps. Web or any other platform is not supported, you can request support for those platform to Google in their repo.

  • This plugin is not sponsored or maintained by Google. The authors are developers excited about Machine Learning that wanted to expose Google's native APIs to Flutter.

  • Google's ML Kit APIs are only developed natively for iOS and Android. This plugin uses Flutter Platform Channels as explained here.

Requirements #

Android #

  • minSdkVersion: 26
  • targetSdkVersion: 35
  • compileSdkVersion: 35

Note: This API is currently only available on Android. iOS support may be added in the future.

Usage #

Prompt #

Create an instance of Prompt

final prompt = Prompt();

Check feature status

final status = await prompt.checkFeatureStatus();
if (status == FeatureStatus.downloadable) {
  await prompt.downloadFeature(
    onDownloadCompleted: () {
      // Start prompt generation
    },
  );
} else if (status == FeatureStatus.available) {
  // Start prompt generation
}

Generate text from prompt

final text = "Write a 3 sentence story about a magical dog.";
final response = await prompt.runInference(text);
print('Response: $response');

Generate text from multimodal prompt (image + text)

final imageData = {
  'type': 'file',
  'path': '/path/to/image.jpg',
};
final text = "What's in this image?";
final response = await prompt.runInference(text, imageData: imageData);
print('Response: $response');

Release resources with close()

prompt.close();

Example app #

Find the example app here.

Contributing #

Contributions are welcome. In case of any problems look at existing issues, if you cannot find anything related to your problem then open an issue. Create an issue before opening a pull request for non trivial fixes. In case of trivial fixes open a pull request directly.

0
likes
140
points
0
downloads

Publisher

verified publisherflutter-ml.dev

Weekly Downloads

A Flutter plugin to use Google's ML Kit GenAI Prompt API to send custom requests to Gemini Nano.

Documentation

API reference

License

MIT (license)

Dependencies

flutter, google_mlkit_commons

More

Packages that depend on google_mlkit_genai_prompt

Packages that implement google_mlkit_genai_prompt