gemini_widgets 0.0.4 copy "gemini_widgets: ^0.0.4" to clipboard
gemini_widgets: ^0.0.4 copied to clipboard

A powerful Flutter package for declarative AI widgets.

Gemini Widgets 🚀 #

pub package License: MIT Pub points

Gemini Widgets is a powerful, declarative Flutter package that makes integrating Google's Gemini AI into your apps as simple as adding a widget. No more manual state management, complex API handling, or boilerplate code.


Why Gemini Widgets? 🤔 #

Traditional AI integration in Flutter requires managing asynchronous states (loading, error, success), handling API keys securely, and writing repetitive code for every AI feature. gemini_widgets abstracts all of that away into high-level components.

  • Declarative API: Just drop a widget and provide a prompt.
  • 🔄 Auto State Management: Built-in handling for loading, error, and success states.
  • 🛠️ Highly Customizable: Use your own builders to match your app's design.
  • 🚀 Minimal Boilerplate: Go from zero to AI-powered UI in minutes.
  • 📈 SEO Optimized: Designed with discoverability and best practices in mind.

Features 🌟 #

  • GenerativeText: Generate creative text, poems, code, or answers from a simple string prompt.
  • GenerativeImage: Create stunning images directly from text descriptions.
  • VisionText: Analyze images and generate textual insights, descriptions, or data extraction.

Getting Started 🏁 #

1. Installation #

Add gemini_widgets to your pubspec.yaml:

dependencies:
  gemini_widgets: ^0.0.2

Then, run:

flutter pub get

2. Initialization #

Get your API key from Google AI Studio. Initialize the package in your main():

import 'package:flutter/material.dart';
import 'package:gemini_widgets/gemini_widgets.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  // Initialize with your API key
  GeminiWidgets.initialize(apiKey: 'YOUR_GEMINI_API_KEY');

  runApp(const MyApp());
}

Usage Examples 💡 #

GenerativeText #

GenerativeText(
  prompt: "Write a short, fun poem about Flutter.",
  loadingBuilder: (context) => const Center(child: CircularProgressIndicator()),
  successBuilder: (context, text) => Text(text ?? "No result"),
  errorBuilder: (context, error) => Text("Error: $error"),
),

GenerativeImage #

GenerativeImage(
  prompt: "A futuristic, sleek Flutter logo, neon blue on a dark background.",
  loadingBuilder: (context) => const CircularProgressIndicator(),
  successBuilder: (context, image) => ClipRRect(
    borderRadius: BorderRadius.circular(12),
    child: image,
  ),
  errorBuilder: (context, error) => Text("Error: $error"),
),

VisionText #

VisionText(
  prompt: "Describe what is in this image in a single sentence.",
  imageBytes: _imageData, // Uint8List
  loadingBuilder: (context) => const CircularProgressIndicator(),
  successBuilder: (context, text) => Text(text ?? "No description."),
  errorBuilder: (context, error) => Text("Error: $error"),
),

Advanced Customization 🛠️ #

You can customize the look and feel of every state by providing your own widgets in the builders. This allows gemini_widgets to blend seamlessly into any design system.


Important Notes ⚠️ #

  • API Key Security: Never hardcode your API key in a public repository. Use environment variables or a secure configuration file.
  • Usage Limits: Refer to Google Gemini's pricing and quota limits for your API key.

License 📜 #

This project is licensed under the MIT License - see the LICENSE file for details.


Contributing 🤝 #

Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request on GitHub.

1
likes
160
points
175
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A powerful Flutter package for declarative AI widgets.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on gemini_widgets