<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Heba Khalifa on Medium]]></title>
        <description><![CDATA[Stories by Heba Khalifa on Medium]]></description>
        <link>https://medium.com/@habatrka?source=rss-67c82c433087------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fJhyrtNx0iVUa1OHD7XNYg.png</url>
            <title>Stories by Heba Khalifa on Medium</title>
            <link>https://medium.com/@habatrka?source=rss-67c82c433087------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:46:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@habatrka/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How GenUI Works Behind the Scenes:
From User Prompt to Flutter Widgets]]></title>
            <link>https://medium.com/@habatrka/how-genui-works-behind-the-scenes-from-user-prompt-to-flutter-widgets-23a4c402a795?source=rss-67c82c433087------2</link>
            <guid isPermaLink="false">https://medium.com/p/23a4c402a795</guid>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Heba Khalifa]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 17:58:41 GMT</pubDate>
            <atom:updated>2026-08-06T18:36:59.534Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>How GenUI Works Behind the Scenes:<br>From User Prompt to Flutter Widgets</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1-izjQ-vVTrUnO1h-DK37g.png" /></figure><p>When I first started learning GenUI, I thought the AI was returning ready-to-use Flutter widgets.</p><p>But after reading the documentation and understanding the architecture behind it, I realized that’s not what actually happens.</p><p>In this article, I’ll walk through the complete journey of a user request — from the moment the user presses Send until the UI is rendered on the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gUwuCnQSy9TrQQCGLsGauw.png" /></figure><h3>1. It All Starts with the User</h3><p>Let’s imagine we’re building a <strong>Quran Khatmah</strong> feature.</p><p>The user simply types what they need into a text field.</p><p>For example:</p><blockquote>“I want to finish reading the Quran in one week and track my progress.”</blockquote><p>At this point, the user doesn’t decide whether the UI should contain a Calendar, Progress Bar, Cards, or Buttons.</p><p>The only thing the user provides is **their intent**.</p><p>Example from my Khatmah feature:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*NoFk5-IX2dAG3HNr3dADaA.jpeg" /><figcaption>The user expresses their intent through a simple text prompt</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dlpXQtR8ugtKKkzf6EVJ1Q.png" /></figure><h3>2. Does the AI Generate Flutter Widgets?</h3><p>This was the biggest misconception I had when I first started learning GenUI.</p><p>I assumed Gemini would generate Flutter widgets directly.</p><p>But that’s not how GenUI works.</p><p>Instead, the AI generates a structured UI Description (also referred to as an A2UI Message).</p><p>At this point you may ask:</p><blockquote><strong><em>If the AI knows what the interface should look like, why doesn’t it render Flutter widgets itself?</em></strong></blockquote><p>The answer is simple.</p><p>Gemini runs on a server.</p><p>It doesn’t have access to the Flutter Engine, nor can it render widgets.</p><p>Its responsibility is to generate a structured description of the interface.</p><p>GenUI then interprets that description and renders real Flutter widgets inside your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*coJ6jCxyOesJWEBzAUX23Q.png" /></figure><h3>3. The Journey Begins</h3><p>Everything starts when the user presses <strong>Send</strong>.<br>conversation.sendRequest(…)<br>This is the entry point of the GenUI flow.</p><p>The <strong>Conversation</strong> receives the user&#39;s request and forwards it to the <strong>A2uiTransportAdapter</strong>.</p><h3>4. Why Do We Need A2uiTransportAdapter?</h3><p>While reading the documentation, one question immediately came to my mind.</p><blockquote><em>Why doesn’t the Transport communicate directly with Gemini?<br></em>The Transport has a single responsibility.</blockquote><p>Its job is to transport messages between GenUI and your AI Service.</p><p>It exposes an onSend callback.</p><p>Whenever the Conversation sends a request, this callback is invoked.</p><p>In my implementation, I connected this callback to my AI Service.</p><p>This separation keeps every component focused on one responsibility, following the Single Responsibility Principle (SRP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*5J64rqSzWZYCHLb11tIpwQ.png" /></figure><h3>5. The AI Service</h3><p>The next step is the AI Service.</p><p>This is where I decide which AI model my application should use.</p><p>In my project, I used <strong>Gemini</strong> through <strong>Firebase AI</strong>.</p><p>The AI Service prepares the prompt, sends it to Gemini, and receives the streamed response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*ZLYo2zOqGwDUgjH8OGuEKg.png" /></figure><h3>6. How Does Gemini Decide the UI?</h3><p>Before generating anything, Gemini relies on three inputs.<br><strong>System Prompt</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YrFxTKBZXqcQvojaQdiM7Q.png" /></figure><p>The System Prompt defines the feature’s rules, expected behavior, and constraints</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*XZ6plbNc5Gt_s1LlNkHJwA.png" /></figure><h4>Catalog</h4><p>The Catalog contains every widget and component that the model is allowed to use.</p><p>Gemini cannot invent new widgets.</p><p>It can only use the components you’ve registered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*J_py22-CCwiaavZ9DwwiRQ.png" /></figure><h4>User Prompt</h4><p>Finally, Gemini receives the user’s request Once it has:</p><ul><li>User Prompt</li><li>System Prompt</li><li>Catalog</li></ul><p>it has everything it needs to generate the interface description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*q1wHzbT7xefXJg0KQjhDcw.png" /></figure><h3>7. Streaming the Response</h3><p>Instead of waiting for the complete response, I used streaming.</p><p><strong>model.generateContentStream(…)<br></strong>Each chunk generated by Gemini is immediately forwarded to the transport adapter.</p><p><strong>transportAdapter.addChunk(…)</strong></p><p>This allows the UI to update progressively while the model is still generating the response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*8mV_kPV_0tHzqSnbgwL8mg.png" /></figure><h3>8. Rendering the UI</h3><p>Once the Conversation receives the streamed UI Description, the SurfaceController updates the current surface.</p><p>Finally, GenUI interprets the UI Description and renders real Flutter widgets.</p><p>This is the moment where the generated interface actually appears on the screen.</p><p>_surfaceController = SurfaceController( catalogs: [catalog], );</p><h3>Final Architecture</h3><p>Now that we’ve explored every component individually, here’s the complete architecture from start to finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gUwuCnQSy9TrQQCGLsGauw.png" /><figcaption>The complete flow can be summarized as follows</figcaption></figure><h3>Conclusion</h3><p>When I first started learning GenUI, I assumed the AI generated Flutter widgets directly.</p><p>After diving into the documentation and understanding the architecture, I realized that the AI’s responsibility is much simpler — and much more powerful.</p><p>The model doesn’t build Flutter widgets.</p><p>Instead, it generates a structured <strong>UI Description</strong> based on three main inputs:</p><ul><li>The user’s prompt</li><li>The System Prompt</li><li>The Catalog</li></ul><p>From there, GenUI takes over. It interprets that description and renders real Flutter widgets using the components you’ve exposed through the Catalog.</p><p>I think this separation of responsibilities is what makes GenUI so flexible. The AI focuses on deciding <strong>what</strong> the interface should be, while GenUI and Flutter are responsible for <strong>how</strong> that interface is rendered.</p><p>Once I understood this flow, the entire architecture became much clearer, and I hope this walkthrough helps make it clearer for you as well.</p><p>— -<br>If you’re just getting started with GenUI, I highly recommend taking some time to understand the architecture before jumping into the code. Once the flow clicks, the entire framework becomes much easier to reason about.</p><p><strong>References</strong></p><ul><li><a href="https://docs.flutter.dev/ai/genui?utm_source=chatgpt.com">Flutter GenUI Documentation</a></li><li><a href="https://docs.flutter.dev/ai/genui/components?utm_source=chatgpt.com">GenUI Components Documentation</a></li><li>Flutter GenUI Codelab</li><li>Firebase AI Logic for Flutter Documentation</li><li><a href="https://ai.google.dev/docs?utm_source=chatgpt.com">Google AI (Gemini) Documentation</a></li></ul><p>Thank you for reading <br>If you have any questions or feedback, I’d love to hear your thoughts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23a4c402a795" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>