generate-images-with-firebase-ai

Generate and edit images from Flutter apps using Firebase AI Logic and Gemini image models.

628|64|Updated Apr 22, 2025
One-click install
npx skills add https://github.com/evanca/flutter-ai-rules --skill generate-images-with-firebase-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generate-images-with-firebase-ai
Source: https://github.com/evanca/flutter-ai-rules/tree/main/skills/generate-images-with-firebase-ai
Command: npx skills add https://github.com/evanca/flutter-ai-rules --skill generate-images-with-firebase-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires firebase_ai, image_picker, and includes references (resource) components.

What problem does it solve?

Image generation from Flutter with Firebase AI Logic fails in non-obvious ways: first calls return empty responses due to billing, App Check, or missing responseModalities settings, and developers waste time debugging correct Dart code when the real problem is project configuration. This Skill provides the working call pattern, response parsing, and troubleshooting order for Gemini image models.

Core Features & Use Cases

  • First-call diagnostics: Rule out the three configuration blockers (Blaze billing, App Check enforcement, responseModalities) before debugging code.
  • Response handling: Walk interleaved text and image parts from a Candidate, report blockReason and finishReason, and handle empty or image-only responses gracefully.
  • Photo input and sizing: Downscale user photos at pick time to avoid main-isolate base64 stalls, and control output with ImageConfig aspect-ratio and size enums.
  • Prompting and testing guidance: Reference files cover prompt failure patterns (placeholder text painted into artwork, wardrobe persistence), and the four test layers from unit tests on response parsing to evals.
  • Use Case: A user uploads a selfie and your Flutter app returns stylized artwork with a matching caption; this Skill covers the model call, photo downscaling, defensive JSON parsing of the caption, and what to do when no image comes back.

Quick Start

Ask your agent to add Gemini image generation to a Flutter screen using Firebase AI Logic, including billing and App Check setup checks.

Frequently Asked Questions about generate-images-with-firebase-ai

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate images in Flutter with Firebase AI Logic?

Call FirebaseAI.googleAI().generativeModel with a Gemini image model ID and set responseModalities to both text and image in GenerationConfig. Then walk the response candidate's parts, collecting InlineDataPart bytes as the image and TextPart content as accompanying text.

Gemini Developer API vs Vertex AI for Firebase image generation?

Prefer the Gemini Developer API via FirebaseAI.googleAI() as the default since it needs minimal setup and text models work on the Spark plan. Choose Vertex AI only when the project already lives in Vertex or you need GCP-side controls; both require Blaze billing for image generation.

Why does my first Firebase AI image request fail or return empty?

First-call failures are almost always configuration, not code: image generation has no free tier so Spark-plan projects hit a zero quota, App Check blocks unattested requests when enabled, and missing responseModalities means the model returns only text. Check these three before debugging Dart.

How do I send a user photo to a Gemini image model in Flutter?

Pick the image with maxWidth and maxHeight caps (around 1280px) at pick time, then pass the bytes as an InlineDataPart with the matching MIME type alongside your TextPart prompt. Downscaling first avoids a multi-second UI freeze from synchronous base64 encoding on the main isolate.

How do I control aspect ratio and size of generated images?

Use ImageConfig with the ImageAspectRatio and ImageSize enums, which are real constraints the model respects. For ratios the enum does not offer, such as 2:1, measure the returned image with ui.ImageDescriptor and lay out from the measurement instead of asking in the prompt.

What can unit tests actually cover for AI image generation?

Unit tests only reach your interpretation of a response: parsing structured text and converting a Candidate into your domain type, using real publicly-constructible SDK types. Whether the image is good or the prompt was understood requires evals with a judge model, not tests.