# Build your own Flutter GenUI solution with Gemini structured outputs

DevFeed: [Build your own Flutter GenUI solution with Gemini structured outputs](<https://devfeed.tech/articles/build-your-own-flutter-genui-solution-with-gemini-structured-outputs-23047.md>)

Original publisher: [Read original article](<https://medium.com/flutter-community/build-your-own-flutter-genui-framework-with-gemini-structured-outputs-a6db3653b9b6?source=rss----86fb29d7cc6a---4>)

Author: Cagatay Ulusoy

Published: 2026-06-09T12:28:28Z

Content type: tutorial

Language: en

Sources: [Flutter Community](<https://devfeed.tech/sources/flutter-community-medium.md>)

Topics: [Flutter](<https://devfeed.tech/topics/flutter.md>), [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>), [Image](<https://devfeed.tech/topics/image.md>), [Learning](<https://devfeed.tech/topics/learning.md>)

Tags: [ai-image-generator](<https://devfeed.tech/tags/ai-image-generator.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [firebase-ai-logic](<https://devfeed.tech/tags/firebase-ai-logic.md>), [flow](<https://devfeed.tech/tags/flow.md>), [flutter](<https://devfeed.tech/tags/flutter.md>), [framework](<https://devfeed.tech/tags/framework.md>), [gemini](<https://devfeed.tech/tags/gemini.md>), [generative-ui](<https://devfeed.tech/tags/generative-ui.md>), [image-generation](<https://devfeed.tech/tags/image-generation.md>), [language-learning](<https://devfeed.tech/tags/language-learning.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [prompt](<https://devfeed.tech/tags/prompt.md>), [schemas](<https://devfeed.tech/tags/schemas.md>), [sdk](<https://devfeed.tech/tags/sdk.md>), [series](<https://devfeed.tech/tags/series.md>), [structured](<https://devfeed.tech/tags/structured.md>), [ui-controls](<https://devfeed.tech/tags/ui-controls.md>)

## AI overview

To reduce repetitive image scenes, the author adds a five-step Flutter refinement flow before image generation. Gemini's lightweight structured-output call plans one topic-aware choice at a time--such as season, setting, action, framing, mood, or visual details--while Flutter renders ordinary controls and stores selections as structured data. Schemas define the UI contract; a finite-state machine, parser, and typed response objects connect each step, and a separate generation call turns the completed choices into learning content and an image prompt. This makes variation come from explicit scene choices rather than relying on sampling settings alone, while keeping UI behavior in Flutter. The hand-built approach requires wiring schemas, parsers, state transitions, selection storage, and widgets for each flow; the author presents that maintenance burden as motivation for a later migration to the official Flutter GenUI SDK.

## Source excerpt

Part 2 of a series "Building Image Assisted Language Learning Practice with Flutter, Firebase and Gemini." Part 1 built the image generation and annotation pipeline. This part buids a generative UI framework by hand, using Gemini structured outputs. Part 3 is the migration: same feature, official Flutter GenUI SDK. In Part 1, I built the first image description practice pipeline for my Flutter app. A user chooses a topic, Firebase and Gemini generate a practice image for the selected topic, and Gemini 3 adds visual annotations on top of the image. That pipeline worked. But after generating enough practices, a different problem became clear. The system could produce valid images, but the variation was limited. For some topics, Gemini kept returning to the same kind of scene, even when the prompt asked for ramdomness explicitly. This post starts one step before image generation. Instead of making the final prompt longer and hoping for more variety, I changed the input flow: what if the user could shape the scene through a guided UI before the image was generated? That led to a five step refinement flow. For each step, Gemini generates topic aware options, such as season, setting, action, framing, mood, and visual details. Flutter renders those options as normal UI controls. The user chooses what they want, and the app stores those choices as structured data before turning them into a more specific image prompt. I did not begin by trying to build a GenUI framework. I was just trying to stop my image generator from repeating itself. But by the end, the system had schemas, widget catalogs, state transitions, and LLM planned screens. So let's start with the original problem. Selected topic: Shopping and errands in Finnish everyday life1. A quick recap My app helps people practice 🇫🇮 Finnish. One of the core exercises is showing the learners a picture and ask them to describe it out loud, then give feedback. The user experience is simple. The content problem behind it is n