<?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[Stac - Medium]]></title>
        <description><![CDATA[Update Flutter apps in seconds without app store approvals - Medium]]></description>
        <link>https://medium.com/stac?source=rss----86d4bb8ece39---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stac - Medium</title>
            <link>https://medium.com/stac?source=rss----86d4bb8ece39---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 02:31:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/stac" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Navigating Like a Pro in Stac: Server-Driven Navigation for Flutter]]></title>
            <link>https://medium.com/stac/navigating-like-a-pro-in-stac-server-driven-navigation-for-flutter-9d4077506996?source=rss----86d4bb8ece39---4</link>
            <guid isPermaLink="false">https://medium.com/p/9d4077506996</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Divyanshu Bhargava]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 13:40:59 GMT</pubDate>
            <atom:updated>2026-03-12T13:50:21.762Z</atom:updated>
            <content:encoded><![CDATA[<h4>Push, pop, replace, and control Flutter navigation dynamically using Stac’s server-driven UI framework.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOiEc9z0AocUt6ONizzddQ.png" /></figure><p>If you’ve been building with Stac, you already know the magic: define your UI in JSON (or Dart!), push it from the server, and watch your Flutter app update without touching the App Store. But there’s one question that comes up <em>a lot</em>:</p><p><strong>“How do I actually navigate between screens?”</strong></p><p>Navigation in Stac follows the same mental model as Flutter’s Navigator. Push screens, pop back, or replace the current one.</p><p>The difference is simple but powerful: <strong>your backend can control navigation.</strong> No redeployment. No waiting for app review.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*fshXY-tbfFqVgNER5_Wm6A.png" /></figure><h3>Where Can You Navigate To?</h3><p>Stac gives you <strong>five</strong> ways to define your destination. Pick the one that fits:</p><p><strong>1. Stac Screen</strong><br>Screens served from <strong>Stac Cloud</strong>.</p><p><strong>2. Flutter Route</strong><br>Your app’s existing named Flutter routes (for example: /settings).</p><p><strong>3. Inline JSON</strong><br>A screen defined directly inside the action JSON.</p><p><strong>4. Asset</strong><br>Bundled JSON screens stored locally in your app for <strong>offline-first flows</strong>.</p><p><strong>5. Network</strong><br>A screen fetched from an API at navigation time.</p><h3>Navigation Styles</h3><p>Before we look at examples, here’s the cheat sheet for <em>how</em> you navigate:</p><p><strong>1. </strong><strong>push</strong><br>Push a new screen on top of the navigation stack.</p><p><strong>2. </strong><strong>pop</strong><br>Go back to the previous screen. You can optionally return data.</p><p><strong>3. </strong><strong>pushReplacement</strong><br>Replace the current screen with a new one.</p><p><strong>4. </strong><strong>pushAndRemoveAll</strong><br>Push a new screen and clear the entire navigation stack.<br>Commonly used for flows like <strong>Login → Home</strong>.</p><p><strong>5. </strong><strong>popAll</strong><br>Pop all screens and return to the root.</p><p><strong>6. </strong><strong>pushNamed</strong><br>Navigate to a Flutter named route (for example: /settings).</p><p>If you’ve worked with Flutter’s Navigator, this should feel right at home.</p><pre>## Navigation Stack<br><br>Login Screen<br>     │<br>     │ push<br>     ▼<br>Detail Screen<br>     │<br>     │ pop<br>     ▼<br>Login Screen</pre><h3>Show Me the Code</h3><p>Enough theory. Let’s see how this works in both <strong>Dart</strong> and <strong>JSON</strong>.</p><h3>Popping Back</h3><p>The simplest one, go back:</p><p><strong>Dart:</strong></p><pre>// Pop current route<br>onPressed: StacNavigator.pop()<br><br>// Pop with a result for the previous screen<br>onPressed: StacNavigator.pop(result: {&#39;saved&#39;: true})<br><br>// Pop all the way back to root<br>onPressed: StacNavigator.popAll()</pre><p><strong>JSON:</strong></p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;navigationStyle&quot;: &quot;pop&quot;<br>}</pre><p>Want to send data back? Add a result:</p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;navigationStyle&quot;: &quot;pop&quot;,<br>  &quot;result&quot;: { &quot;saved&quot;: true }<br>}</pre><h3>Pushing a Stac Screen</h3><p>Got a screen called detail_screen in your /stac folder? Navigate to it like this:</p><p><strong>Dart:</strong></p><pre>StacNavigator.pushStac(&#39;detail_screen&#39;, arguments: {&#39;id&#39;: &#39;123&#39;})</pre><p><strong>JSON:</strong></p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;routeName&quot;: &quot;detail_screen&quot;,<br>  &quot;navigationStyle&quot;: &quot;push&quot;,<br>  &quot;arguments&quot;: { &quot;id&quot;: &quot;123&quot; }<br>}</pre><p>Clean and simple. Your backend can swap detail_screen with anything it wants.That&#39;s the SDUI superpower right there. 💪</p><h3>Pushing a Flutter Named Route</h3><p>Already have a /settings route defined in your Flutter app? No problem — Stac plays nicely with your existing routes:</p><p><strong>Dart:</strong></p><pre>StacNavigator.pushFlutter(&#39;/settings&#39;, arguments: {&#39;tab&#39;: &#39;profile&#39;})</pre><p><strong>JSON:</strong></p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;routeName&quot;: &quot;/settings&quot;,<br>  &quot;navigationStyle&quot;: &quot;pushNamed&quot;,<br>  &quot;arguments&quot;: { &quot;tab&quot;: &quot;profile&quot; }<br>}</pre><p>📝 <strong>Note:</strong> Use pushNamed, pushReplacementNamed, or pushNamedAndRemoveAll for Flutter routes. The non-Named variants (push, pushReplacement, etc.) are for Stac screens.</p><h3>Pushing an Inline JSON Screen</h3><p>Sometimes you don’t want a separate screen file. You just want to define the screen <em>right there</em> in the action. Hold my JSON:</p><p><strong>Dart:</strong></p><pre>StacNavigator.pushJson({<br>  &quot;type&quot;: &quot;scaffold&quot;,<br>  &quot;appBar&quot;: {<br>    &quot;type&quot;: &quot;appBar&quot;,<br>    &quot;title&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;data&quot;: &quot;Detail&quot; }<br>  },<br>  &quot;body&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;data&quot;: &quot;Hello from inline JSON!&quot; }<br>})</pre><p><strong>JSON:</strong></p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;navigationStyle&quot;: &quot;push&quot;,<br>  &quot;widgetJson&quot;: {<br>    &quot;type&quot;: &quot;scaffold&quot;,<br>    &quot;appBar&quot;: {<br>      &quot;type&quot;: &quot;appBar&quot;,<br>      &quot;title&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;data&quot;: &quot;Detail&quot; }<br>    },<br>    &quot;body&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;data&quot;: &quot;Hello from inline JSON!&quot; }<br>  }<br>}</pre><p>Is it a bit wild? Yes. Is it useful for quick prototypes or one-off screens? Absolutely.</p><h3>Pushing from an Asset</h3><p>Offline-first? Bundle your screen JSON as an asset:</p><p><strong>Dart:</strong></p><pre>StacNavigator.pushAsset(&#39;assets/screens/detail.json&#39;)</pre><p><strong>JSON:</strong></p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;navigationStyle&quot;: &quot;push&quot;,<br>  &quot;assetPath&quot;: &quot;assets/screens/detail.json&quot;<br>}</pre><h3>Pushing from the Network 🌐</h3><p>This is where it gets really interesting. Fetch a screen from an API <em>at navigation time</em>:</p><p><strong>Dart:</strong></p><pre>StacNavigator.pushNetwork(<br>  StacNetworkRequest(url: &#39;https://api.example.com/screen&#39;, method: Method.get),<br>)</pre><p><strong>JSON:</strong></p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;navigationStyle&quot;: &quot;push&quot;,<br>  &quot;request&quot;: {<br>    &quot;url&quot;: &quot;https://api.example.com/screen&quot;,<br>    &quot;method&quot;: &quot;get&quot;<br>  }<br>}</pre><p>Your server returns a Stac widget tree, and it gets pushed as a new route. Think about it — your entire screen is served at runtime. A/B testing, personalized flows, feature flags… all without a new build. 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/0*bQH0LzEDiiDd375k" /></figure><h3>The Login → Home Classic</h3><p>Every app has it. The user logs in, and you want to push them to the home screen while nuking the entire navigation stack so they can’t “back button” their way to the login page.</p><p><strong>Dart:</strong></p><pre>// Replace current screen<br>StacNavigator.pushReplacementStac(&#39;home_screen&#39;, result: {&#39;loggedIn&#39;: true})</pre><pre>// Or go nuclear — push and remove everything<br>StacNavigator.pushAndRemoveAllStac(&#39;home_screen&#39;)</pre><p><strong>JSON:</strong></p><pre>{<br>  &quot;actionType&quot;: &quot;navigate&quot;,<br>  &quot;routeName&quot;: &quot;home_screen&quot;,<br>  &quot;navigationStyle&quot;: &quot;pushAndRemoveAll&quot;<br>}</pre><p>No more accidental back-to-login. Your users will thank you. Your QA team will <em>definitely</em> thank you.</p><h3>Quick Reference: Dart Helpers</h3><p>StacNavigator gives you type-safe helpers so you&#39;re not hand-building JSON action objects in Dart:</p><ul><li><strong>Pop:</strong> StacNavigator.pop(), StacNavigator.popAll()</li><li><strong>Stac screens:</strong> pushStac(), pushReplacementStac(), pushAndRemoveAllStac()</li><li><strong>Flutter routes:</strong> pushFlutter(), pushReplacementFlutter(), pushAndRemoveAllFlutter()</li><li><strong>Inline JSON:</strong> pushJson() (+ replacement and removeAll variants)</li><li><strong>Assets:</strong> pushAsset() (+ variants)</li><li><strong>Network:</strong> pushNetwork() (+ variants)</li></ul><p>Every push variant follows the same pattern. Learn one, you know them all.</p><h3>Wrapping Up</h3><p>Navigation in Stac isn’t a new paradigm; it’s Flutter’s Navigator made server-driven. You get the same push/pop/replace model you&#39;re used to, with the added flexibility of driving it entirely from JSON or your backend.</p><p>Whether you’re pushing a local Stac screen, a Flutter named route, an inline widget tree, a bundled asset, or a screen fetched from an API, it all works the same way.</p><p>That’s the Stac way. ✌️</p><h3>Ready to Try Stac?</h3><p>Start building with Stac and explore how server-driven UI can simplify your Flutter apps.</p><p>🔗 <strong>Docs:</strong> docs.stac.dev<br>💻 <strong>GitHub:</strong> github.com/StacDev/stac<br>💬 <strong>Discord:</strong> discord.gg/vTGsVRK86V</p><p>Have questions or want to share what you’re building? Come hang out in the Discord. We’d love to see what you build with Stac.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d4077506996" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stac/navigating-like-a-pro-in-stac-server-driven-navigation-for-flutter-9d4077506996">Navigating Like a Pro in Stac: Server-Driven Navigation for Flutter</a> was originally published in <a href="https://medium.com/stac">Stac</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Dynamic Themes in Stac]]></title>
            <link>https://medium.com/stac/introducing-dynamic-themes-stac-97084dcce4c6?source=rss----86d4bb8ece39---4</link>
            <guid isPermaLink="false">https://medium.com/p/97084dcce4c6</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Mithul Nayagam]]></dc:creator>
            <pubDate>Wed, 14 Jan 2026 10:32:46 GMT</pubDate>
            <atom:updated>2026-01-14T10:46:55.154Z</atom:updated>
            <content:encoded><![CDATA[<h4>Update your Flutter app theme dynamically at runtime.</h4><figure><img alt="Banner image announcing Dynamic Themes in Stac, featuring a dark and a light mobile app interface" src="https://cdn-images-1.medium.com/max/1024/1*3joZkrF92NLaYDDkrOn1ZA.png" /></figure><p><strong>Stac </strong><a href="https://pub.dev/packages/stac"><strong>v1.2.0</strong></a><strong> just dropped</strong>, and with it we’re introducing support for a powerful new feature - <strong>Dynamic Theming</strong>.</p><p>Stac has always focused on enabling fully server-driven UI in Flutter, allowing teams to define screens, widgets, and actions using JSON and update them without redeploying their apps. With this release, that same approach now extends to theming.</p><p>No longer are you bound to the Colors, typography, brightness, and other visual properties defined at build time. Instead, they can now be defined and updated dynamically at runtime using Stac’s new dynamic theming model.</p><h4>Why Dynamic Themes Matter</h4><p>We’re fresh out of the holiday season, and many of the apps we use every day looked noticeably different just a few weeks ago.</p><p>Logos were wrapped in festive colors. Backgrounds shifted to reds and greens. Buttons, banners, and typography subtly changed to reflect Christmas, New Year’s, or year-end campaigns. And almost as quickly as they appeared, those themes disappeared, replaced by the default look of the app again.</p><figure><img alt="Standard and Christmas themed UI for the Food Delivery App Swiggy" src="https://cdn-images-1.medium.com/max/1024/1*4lEpHBW6Cry_w3S5LkKEpw.png" /><figcaption>An example of a seasonal UI refresh used for a holiday campaign</figcaption></figure><p>Traditionally, pulling this off at scale means planning releases weeks in advance, and hoping users update in time. Even with server-driven UI, while layouts and content can be changed easily, <strong>visual identity is often still locked behind a build</strong>.</p><p>This is where dynamic themes take things to the next level.</p><p>With Stac’s server-driven UI, teams already have the ability to roll out campaign-specific screens without redeploying their Flutter apps. Dynamic theming extends that same flexibility to the <em>entire base look and feel</em> of the app. Colors, typography, and brightness can now shift alongside your content, instantly and remotely.</p><p>A holiday campaign no longer needs a dedicated app release. A New Year refresh doesn’t require waiting for approval. Seasonal branding, limited-time promotions, or even one-day visual experiments can all be driven from the backend and rolled back just as easily.</p><p>Dynamic themes turn visual styling into a runtime decision. Combined with SDUI, this means your app can evolve visually at any time without the overhead of release cycles.</p><h3>Adding Dynamic Themes to the Stac Movie App</h3><p>In this section, we’ll use a simplified version of the Stac example <a href="https://github.com/StacDev/stac/tree/dev/examples/movie_app">Movie app</a>, with Stac and the CLI already set up. We’ll walk through the process step by step to move the app’s theme into the <strong>Stac Cloud</strong> and have the application fetch it dynamically at runtime.</p><figure><img alt="The Stac example Movie App" src="https://cdn-images-1.medium.com/max/1024/1*iWtXoA9yodLybiVPPF3kgA.png" /></figure><p><em>This guide assumes you’re already familiar with Stac. If you’re new, we recommend reviewing the documentation or earlier blog posts before continuing.</em></p><p><a href="https://docs.stac.dev/introduction">Introduction - Stac</a></p><h4>Existing Movie App</h4><p>At the moment, the app already uses StacTheme, but the theme is defined locally in code and shipped with the app.</p><p>A simplified version of the existing theme looks like this:</p><pre>import &#39;package:stac_core/stac_core.dart&#39;;<br><br>/// Dark theme for the Movie App.<br>StacTheme get myTheme {<br>  return StacTheme(<br>    brightness: StacBrightness.dark,<br>    colorScheme: StacColorScheme(<br>      brightness: StacBrightness.dark,<br>      primary: &#39;#95E183&#39;,<br>      onPrimary: &#39;#050608&#39;,<br>      secondary: &#39;#95E183&#39;,<br>      onSecondary: &#39;#FFFFFF&#39;,<br>      surface: &#39;#050608&#39;,<br>      onSurface: &#39;#FFFFFF&#39;,<br>      onSurfaceVariant: &#39;#65FFFFFF&#39;,<br>      error: &#39;#FF6565&#39;,<br>      onError: &#39;#050608&#39;,<br>      outline: &#39;#80FFFFFF&#39;,<br>    ),<br>  );<br>}</pre><p>Here, the theme is defined as a function that returns a StacTheme object. StacTheme is Stac’s DSL equivalent of Flutter’s ThemeData. The overall structure is intentionally very similar, making it easy to translate an existing Flutter theme into Stac.</p><p>One notable difference is how values are expressed. For example, colors are defined using <strong>hex strings</strong> instead of Flutter’s Color objects. StacTheme and Stac DSL are covered in more detail in the <a href="https://docs.stac.dev/introduction">Stac Docs</a>.</p><p>main.dart wires this theme directly into the app:</p><pre>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return StacApp(<br>      title: &#39;Stac Movie App&#39;,<br>      theme: myTheme,<br>      homeBuilder: () {<br>        return Stac(routeName: &#39;onboarding_screen&#39;);<br>      },<br>    );<br>  }<br>}</pre><p>StacApp bootstraps the application using the locally defined theme, while the UI itself is resolved dynamically. In this case, the onboarding_screen is fetched from Stac Cloud at runtime.</p><p>This approach already improves consistency over Flutter’s ThemeData, but the theme is still bundled via the app, and hence locked to code updates in the release cycle</p><p>Next, we’ll move this theme definition into Stac’s DSL.</p><h4>Defining the Theme Using Stac DSL</h4><p>To make the theme dynamic, we move the theme definition into the stac/ folder and express it using Stac DSL.</p><figure><img alt="A code editor showing the project folder structure, with a stac directory expanded and a theme DSL file highlighted inside it." src="https://cdn-images-1.medium.com/max/332/1*UzxXrpJwlltuh2HO3dLxEA.png" /></figure><p>The DSL is still Dart, but it’s declarative and designed to be processed and deployed by Stac, similar to how screens and widgets are defined.</p><p>Below is a simplified example of a theme definition for the Movie App. For clarity, we’ll focus only on <strong>brightness</strong> and <strong>color scheme</strong>, leaving out advanced sub-themes.</p><pre>import &#39;package:stac_core/stac_core.dart&#39;;<br><br>@StacThemeRef(name: &#39;movie_app_theme&#39;)<br>StacTheme get movieAppTheme =&gt; StacTheme(<br>  brightness: StacBrightness.dark,<br>  colorScheme: StacColorScheme(<br>    brightness: StacBrightness.dark,<br>    primary: &#39;#95E183&#39;,<br>    onPrimary: &#39;#050608&#39;,<br>    secondary: &#39;#95E183&#39;,<br>    onSecondary: &#39;#FFFFFF&#39;,<br>    surface: &#39;#050608&#39;,<br>    onSurface: &#39;#FFFFFF&#39;,<br>    onSurfaceVariant: &#39;#65FFFFFF&#39;,<br>    error: &#39;#FF6565&#39;,<br>    onError: &#39;#050608&#39;,<br>    outline: &#39;#80FFFFFF&#39;,<br>  ),<br>);</pre><p>In the next step, we’ll deploy this theme so it can be resolved dynamically by the app.</p><h4>Deploying the Theme</h4><p>Once the theme DSL is defined, deploy it using the Stac CLI.<br>From the project root, run:</p><pre>stac deploy</pre><p>This uploads the theme configuration to the Stac Console alongside your screens if you had defined any. The output should look something like this:</p><pre>[INFO] Building project before deployment...<br>[INFO] Found 4 @StacScreen annotated function(s)<br>[SUCCESS] ✓ Generated screen: onboarding_screen.json<br>[SUCCESS] ✓ Generated screen: home_screen.json<br>[SUCCESS] ✓ Generated screen: detail_screen.json<br>[INFO] Found 1 @StacThemeRef definition(s) in stac\app_theme.dart<br>[SUCCESS] ✓ Generated theme: movie_app_theme.json<br>[SUCCESS] Build completed successfully!<br>[INFO] Deploying screens/themes to cloud...<br>[SUCCESS] Uploaded screen: onboarding_screen.json<br>[SUCCESS] Uploaded screen: home_screen.json<br>[SUCCESS] Uploaded screen: detail_screen.json<br>[SUCCESS] Uploaded theme: movie_app_theme.json<br>[SUCCESS] Deployment completed successfully!</pre><p>When the theme DSL is processed, the Stac CLI generates the following JSON. This output is written to stac/.build/themes and is what gets deployed to Stac Cloud.</p><pre>{<br>  &quot;colorScheme&quot;: {<br>    &quot;brightness&quot;: &quot;dark&quot;,<br>    &quot;primary&quot;: &quot;#95E183&quot;,<br>    &quot;onPrimary&quot;: &quot;#050608&quot;,<br>    &quot;secondary&quot;: &quot;#95E183&quot;,<br>    &quot;onSecondary&quot;: &quot;#FFFFFF&quot;,<br>    &quot;error&quot;: &quot;#FF6565&quot;,<br>    &quot;onError&quot;: &quot;#050608&quot;,<br>    &quot;surface&quot;: &quot;#050608&quot;,<br>    &quot;onSurface&quot;: &quot;#FFFFFF&quot;,<br>    &quot;onSurfaceVariant&quot;: &quot;#65FFFFFF&quot;,<br>    &quot;outline&quot;: &quot;#80FFFFFF&quot;<br>  },<br>  &quot;brightness&quot;: &quot;dark&quot;<br>}</pre><h3>Updating App to use the Dynamic Theme</h3><p>Finally, we update main.dart so the app no longer depends on a locally defined theme.</p><pre>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return StacApp(<br>      title: &#39;Stac Movie App&#39;,<br>      theme: StacAppTheme(name: &quot;movie_app_theme&quot;),<br>      homeBuilder: (_) {<br>        return Stac(routeName: &#39;onboarding_screen&#39;);<br>      },<br>    );<br>  }</pre><p>The app’s theme is now resolved dynamically by Stac at runtime, based on what’s deployed on the cloud.</p><p>You can tweak the theme DSL however you want, be it change colors, switch brightness, adjust typography, or experiment with different styles. I for one think the app would look amazing in Orange</p><pre>import &#39;package:stac_core/stac_core.dart&#39;;<br><br>@StacThemeRef(name: &#39;movie_app_theme&#39;)<br>StacTheme get movieAppTheme =&gt; StacTheme(<br>  brightness: StacBrightness.dark,<br>  colorScheme: StacColorScheme(<br>    brightness: StacBrightness.dark,<br>    primary: &#39;#E76946&#39;, //changed to orange<br>    onPrimary: &#39;#050608&#39;,<br>    secondary: &#39;#E76946&#39;, //changed to orange<br>    onSecondary: &#39;#FFFFFF&#39;,<br>    surface: &#39;#050608&#39;,<br>    onSurface: &#39;#FFFFFF&#39;,<br>    onSurfaceVariant: &#39;#65FFFFFF&#39;,<br>    error: &#39;#FF6565&#39;,<br>    onError: &#39;#050608&#39;,<br>    outline: &#39;#80FFFFFF&#39;,<br>  ),<br>);</pre><p>All we need to do now is run stac deployto update the theme on the cloud and the changes should be reflected on the app.</p><figure><img alt="The Stac example Movie app with an Orange Theme" src="https://cdn-images-1.medium.com/max/1024/1*B_hLP6AXZLxnJ5K6AXkwUA.png" /></figure><p>You can have a look at the full Movie App example source here :</p><p><a href="https://github.com/StacDev/stac/tree/dev/examples/movie_app">stac/examples/movie_app at dev · StacDev/stac</a></p><p>Check out our docs for more info on Stac Themes :</p><p><a href="https://docs.stac.dev/concepts/theming">Theming - Stac</a></p><h3>Conclusion</h3><p>Dynamic theming completes an important piece of the server-driven UI story in Stac. By moving themes into Stac Cloud, visual styling becomes just as flexible and runtime-driven as layouts, widgets, and actions.</p><p>This approach removes theming from the release cycle entirely. Seasonal campaigns, branding updates, accessibility improvements, and visual experiments can now be rolled out instantly and safely without rebuilding or resubmitting your app.</p><p>Combined with Stac’s existing SDUI capabilities, dynamic themes give teams full control over both <strong>structure and style</strong>, enabling truly adaptive Flutter applications.</p><h3>Thanks for Reading</h3><p>Thanks for taking the time to read through this walkthrough. I’m excited to see how dynamic theming helps you build more flexible and expressive apps with Stac.</p><p>If you have feedback, ideas, or questions, do let me know in the comments</p><p>Happy building.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97084dcce4c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stac/introducing-dynamic-themes-stac-97084dcce4c6">Introducing Dynamic Themes in Stac</a> was originally published in <a href="https://medium.com/stac">Stac</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How top tech companies use Server-Driven UI to move faster⚡]]></title>
            <link>https://medium.com/stac/how-top-tech-companies-use-server-driven-ui-to-move-faster-01ae4c71f7ba?source=rss----86d4bb8ece39---4</link>
            <guid isPermaLink="false">https://medium.com/p/01ae4c71f7ba</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rahul Bisht]]></dc:creator>
            <pubDate>Sat, 22 Nov 2025 15:58:57 GMT</pubDate>
            <atom:updated>2025-11-22T17:19:41.558Z</atom:updated>
            <content:encoded><![CDATA[<h4>A deep dive into how leading companies build mobile experiences with Server-Driven UI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8vucG1eGv9EX5srlr_9fww.png" /></figure><p>Open any top mobile app today, and you are likely already seeing Server-Driven UI in action without even realizing it. The reason these apps can roll out new screens, tweak layouts, or run experiments without waiting for an update is simple: the server is driving the UI. What began as a clever workaround for faster iteration has matured into a proven pattern used by the world’s fastest moving teams. Companies rely on it because it helps them ship changes instantly, personalize experiences deeply, and keep every platform perfectly aligned.</p><h3>What is Server-Driven UI? ｡𖦹°‧</h3><p>Server-Driven UI (SDUI) flips the traditional mobile app model. Instead of shipping every screen’s structure, layout, and content inside the app binary, the backend returns a description (typically JSON or XML) that tells the app which components to render, how to arrange them, and which actions to attach. This lets us change UI and content without shipping a new app version &amp; skipping app store approvals!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*8piJwbXbPLdGYI-OfeSibw.jpeg" /></figure><p>A helpful way to picture this is to think about how a browser works. The browser doesn’t know the webpage in advance. It simply knows how to interpret HTML and render it. SDUI works the same way. The app understands a set of predefined components, while the server decides which ones appear and how they fit together.</p><h3>Companies actively building with SDUI 🤝</h3><p>SDUI has gained significant love and traction over recent years. Large enterprises have contributed greatly towards it’s growth and adoption. Here’s a non-exhaustive list of companies and how they are using SDUI,</p><ul><li><strong>Netflix </strong>— enabling targeted lifecycle flows</li><li><strong>Airbnb (Lona &amp; Ghost)</strong> — faster rollout and consistent layout across platforms (<a href="https://medium.com/airbnb-engineering/a-deep-dive-into-airbnbs-server-driven-ui-system-842244c5f5">know more</a>)</li><li><strong>Delivery Hero (Fluid)</strong>— reducing time to market (<a href="https://deliveryhero.jobs/blog/primer-on-delivery-heros-server-driven-ui-platform/">know more</a>)</li><li><strong>Uber</strong> — enabling rapid development and safe experimentation</li><li><strong>Shopify</strong> — improving merchant experience via personalisation (<a href="https://shopify.engineering/server-driven-ui-in-shop-app">know more</a>)</li><li><strong>Meta</strong> — rapid iterations and experimentation</li><li><strong>Lyft</strong> — reducing business complexity and increasing release velocity (<a href="https://eng.lyft.com/the-journey-to-server-driven-ui-at-lyft-bikes-and-scooters-c19264a0378e">know more</a>)</li><li><strong>PhonePe (LiquidUI)</strong> — making product maintenance and updates easy and efficient (<a href="https://tech.phonepe.com/introducing-liquidui-phonepes-server-driven-ui-framework/">know more</a>)</li><li><strong>Zalondo (Appcraft)</strong> — enabling dynamic user personalization (<a href="https://engineering.zalando.com/posts/2024/05/appcraft.html">know more</a>)</li><li><strong>Nubank</strong> <strong>(BDC)</strong>— improving dev speed, control, and reducing time to market (<a href="https://building.nubank.com/server-driven-ui-framework-at-nubank/">know more</a>)</li></ul><p>&amp; many more :)</p><h3>Use cases where SDUI shines! ✨</h3><p>SDUI is useful in a lot of practical and repetitive scenarios for startups and enterprises.</p><ol><li><strong>Faster product iteration &amp; update adoption</strong><br>Real-time mobile app updates without waiting for app store approvals. Your updates always get 100% usage coverage instantly.</li><li><strong>Feature experimentation &amp; A/B testing</strong><br>Swap entire screens or UI treatments from the server to run experiments across millions of users without releasing a new app version or waiting for app store approvals.</li><li><strong>User personalization</strong><br>Show different layouts or CTAs depending on user cohort, eligibility, or recent behavior. Netflix explicitly framed SDUI to manage lifecycle touchpoints from the backend.</li><li><strong>Cross-platform parity</strong><br>Keep web, Android, and iOS aligned by driving UI descriptions from a single source of truth and rendering them natively on each platform.</li><li><strong>Fast rollback and flow control</strong><br>Quickly disable or change problematic flows (payment screens, legal notices, region-specific content) or rollback instantly from server.</li></ol><h3>Enterprise case studies 🏢</h3><p>Below are condensed case-style takeaways drawn from public engineering posts and talks (lessons companies reported):</p><h4>Airbnb / Ghost</h4><p><em>Source: </em><a href="https://medium.com/airbnb-engineering/a-deep-dive-into-airbnbs-server-driven-ui-system-842244c5f5"><em>The Airbnb Tech Blog</em></a></p><p>Airbnb’s love for SDUI is so great that they built multiple super cool internal systems (Lona &amp; Ghost). Ghost is used for faster rollouts and Lona to generate and drive UI definitions centrally. Let’s look into their Ghost Platform (GP) 👀</p><blockquote>The Ghost Platform (GP) is a unified, opinionated, server-driven UI system that enables us to iterate rapidly and launch features safely across web, iOS, and Android. It is called Ghost because our primary focus is around ‘<strong>G</strong>uest’ and ‘<strong>Host</strong>’ features, the two sides to our Airbnb apps.</blockquote><blockquote>GP provides web, iOS, and Android frameworks in each client’s native languages (Typescript, Swift, and Kotlin, respectively) that enable developers to create server-driven features with minimal setup.</blockquote><p>GP was built to speed up product development across iOS, Android, and Web. Instead of each client reconstructing the UI from raw data, the server sends both the content and the layout instructions. This reduces duplicated UI logic across platforms, cuts down on engineering overhead, and allows Airbnb to ship interface changes much faster, often without requiring app-store updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fXEifJg-t6eAjLfR" /></figure><p>The system is organized around a unified GraphQL schema that defines reusable “sections” of UI and the “screens” that assemble them. Clients simply interpret these instructions on each platform in their native languages (i.e., Typescript, Swift, Kotlin). Because sections are modular and composable, Airbnb can run experiments, update flows, or fix issues more consistently across platforms.</p><p>Airbnb continues improving the platform with more composability and tools that let designers and non-engineers configure UI without heavy client-side changes. Overall, the shift to server-driven UI has created a more flexible, maintainable, and scalable product development pipeline for them.</p><h4>Delivery Hero / Fluid</h4><p><em>Source: </em><a href="https://deliveryhero.jobs/blog/primer-on-delivery-heros-server-driven-ui-platform/"><em>D</em>elivery Hero Tech Blog</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0u4MptGeP8seYU0HuXP4g.jpeg" /></figure><blockquote>Fluid is our SDUI platform that decouples the UI from the app release cycle. Essentially, it reduces our time to value by facilitating rapid product iterations.</blockquote><blockquote>-Delivery Hero Team</blockquote><p>Fluid was built to solve for release bottlenecks, low update adoption, logic duplication on multiple platforms and app rigidity. Their team had super clear design goals during implementation and has worked greatly in building up their feature set.</p><p>Fluid platform is built around templates, widget models, and widget factories: a template represents a reusable UI fragment, which the client decodes and uses to create native UI dynamically. The architecture supports robust performance, offline caching, type-safe data binding, and versioning to manage both forward and backward compatibility. Design constraints are applied via the template editor to maintain consistency and scalability while teams still retain flexibility.</p><p>Delivery Hero’s team has been following Airbnb’s SDUI journey since the old days (like us!). You can read the notable differences between libraries in their full blog.</p><h4>Nubank</h4><p><em>Source: </em><a href="https://building.nubank.com/server-driven-ui-framework-at-nubank/"><em>Nubank Blog</em></a></p><blockquote>Backend Driven Content (BDC) platform is the name of our internal Server Driven UI framework at Nubank. We usually say that BDC works as a Lego manual for the Nu app. It tells how to use the “building blocks” available to build the interface to the end user. So, when developing with BDC, our developers are basically writing these “Lego manuals”.</blockquote><blockquote>-Nubank Team</blockquote><p>Nubank developed BDC to address the challenges of delivering frequent updates and new features across its app ecosystem. By leveraging a server-driven UI model, Nubank moved beyond the traditional paradigm where layouts and interactions are entirely embedded in the mobile client. Instead, thier app now receives instructions from the backend not only for data, but also for how to build, display and respond to UI components.</p><p>This architectural shift brought several practical advantages: product teams gained the ability to control feature rollout, perform A/B tests, and adjust interfaces in real time without waiting for app-store approvals. Equally important, the system is aligned with Nubank’s design system and built on top of their tech stack (Flutter for mobile and Clojure for backend services) ensuring consistency and maintainability.</p><p>Since its introduction, the BDC platform has achieved meaningful adoption: around 70% of new screens and flows are built using it, and approximately 43% of the app is already powered by the system. The success can be attributed not just to technology, but to a culture of experimentation, internal collaboration, and developer advocacy.</p><h3>When SDUI is not the right fit 🚫</h3><p>SDUI is powerful, but it is not the right choice for every part of your app. Here are scenarios where a traditional client-driven approach works better:</p><ol><li><strong>Heavy animations or game like interactions</strong><br>Flows with complex motion, custom gestures, or extremely high FPS requirements should stay fully native. SDUI can describe layouts, but it is not built to orchestrate advanced animation timelines.</li><li><strong>Screens with deep client side logic</strong><br>If the screen depends on local state, offline logic, or rapid in-app calculations, pushing the layout to the server can make the flow harder to manage.</li><li><strong>Highly custom designs that don’t repeat</strong><br>If a screen is extremely bespoke and unlikely to change often, the cost of modeling it in SDUI may outweigh the benefit.</li><li><strong>Performance sensitive surfaces</strong><br>Screens like camera views, editors, maps, and AR layers usually demand direct native rendering for maximum performance.</li><li><strong>Poorly defined design systems</strong><br>SDUI works best when there is a strong design system and stable component library. If the component inventory is inconsistent or changing daily, SDUI becomes harder to maintain.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*49uewMhIfTLA2IxNyJgIYg.png" /></figure><h3><strong>Open-source </strong>tools &amp; frameworks 🛠️</h3><p>There are multiple ways to implement SDUI, from homegrown libraries to open-source frameworks and platform integrations. Here’s a list of great open-source projects:</p><ul><li><strong>Stac (Flutter) </strong><a href="https://stac.dev/">Website</a> | <a href="https://github.com/StacDev/stac">Github</a><br>Stac is a platform for Server Driven UI in Flutter, combining a flexible framework with the <a href="https://docs.stac.dev/cli">Stac CLI</a> and <a href="https://console.stac.dev/">Stac Cloud</a>. You can build, update, and ship dynamic interfaces instantly, without redeploying your app. Simple to adopt, powerful in production, and backed by a supportive developer community :)</li><li><strong>rfw (Flutter) </strong><a href="https://pub.dev/packages/rfw">Pub</a> | <a href="https://github.com/flutter/packages/tree/main/packages/rfw">Github</a><br>rfw provides a mechanism for rendering widgets based on declarative UI descriptions that can be obtained at runtime. It is maintained by Flutter and is slowly gaining traction. There is a small learning curve, but overall solid.</li><li><strong>Divkit (Multi-Platform) </strong><a href="http://divkit.tech/en/">Website</a> | <a href="https://github.com/divkit/divkit">Github</a><br>Divkit allows you to roll out server-sourced updates to different app versions. Also, it can be used for fast UI prototyping, allowing you to write a layout once and then ship it to iOS, Android, and Web platforms.</li><li><strong>Rise Tools (React Native) </strong><a href="https://rise.tools/">Website</a> | <a href="https://github.com/rise-tools/rise-tools">Github</a><br>Rise allows you to tweak and expand the UI of your React Native app while it is in production, without rebuilding or redeploying your code.</li></ul><h3><strong>Outro ⭐</strong></h3><p>At Stac, our mission is to advance the future of Server Driven UI and bring its full potential to the Flutter ecosystem. SDUI delivers clear advantages for almost every type of app, yet its awareness and adoption are still far from where they should be. We’re committed to changing that.</p><p>If you want to follow our journey more closely, join our <a href="https://discord.com/invite/vTGsVRK86V">Discord community</a> and consider giving us a <a href="https://github.com/StacDev/stac">star on GitHub</a>. Your support helps us push the SDUI ecosystem forward.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01ae4c71f7ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stac/how-top-tech-companies-use-server-driven-ui-to-move-faster-01ae4c71f7ba">How top tech companies use Server-Driven UI to move faster⚡</a> was originally published in <a href="https://medium.com/stac">Stac</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Stac 1.0]]></title>
            <link>https://medium.com/stac/introducing-stac-1-0-00802abf5f6e?source=rss----86d4bb8ece39---4</link>
            <guid isPermaLink="false">https://medium.com/p/00802abf5f6e</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[stac]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[server-driven-ui]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Divyanshu Bhargava]]></dc:creator>
            <pubDate>Thu, 09 Oct 2025 18:33:37 GMT</pubDate>
            <atom:updated>2025-10-09T18:33:27.836Z</atom:updated>
            <content:encoded><![CDATA[<h4>Dart-to-JSON, CLI, Cloud, and a lot more!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*OjHdtN34Vd5Ww42RhU_JuA.png" /></figure><h3>Introduction</h3><p>After months of development, feedback, and iteration, we’re proud to announce the release of <strong>Stac 1.0</strong>. This isn’t just another update; it’s a milestone. With this release, Stac officially transitions from an <em>experimental project</em> into a <strong>production-ready framework</strong> that teams can confidently build upon.</p><p>Here are a few milestones that brought us here:</p><ul><li><strong>10,000+ </strong>monthly downloads on <a href="https://pub.dev/packages/stac">Pub.dev</a></li><li><strong>600+ </strong><a href="https://github.com/StacDev/stac">GitHub</a> stars</li><li>Countless cycles of <strong>feedback, bug fixes, and improvements</strong></li></ul><h3>Our Thought Process Behind 1.0</h3><p>The <strong>inspiration</strong> behind Stac has always been simple. To empower Flutter teams to <strong>push UI updates instantly</strong> without waiting for App Store or Play Store approvals.</p><p>Earlier versions of Stac solved this core challenge, but through our own use and community feedback, we found areas that needed rethinking.</p><h4>What Was Holding Us Back</h4><ul><li><strong>JSON is Painful:</strong> As frontend developers, we love writing Dart — not wrestling with raw JSON.</li><li><strong>Missing server pieces: </strong>Mobile teams still had to manually host, deploy, and validate their JSON files, often relying on backend developers. This dependency slowed down iteration and created unnecessary disconnects.</li><li><strong>Hard-to-catch errors: </strong>Without robust error logging, diagnosing and fixing issues was frustratingly difficult.</li><li><strong>No central control: </strong>There was no dashboard or CLI to manage or monitor Stac projects — everything was scattered and manual.</li></ul><h3>Welcome, Stac 1.0 🚀</h3><p>After countless nights, caffeine overloads, and thousands of rewritten lines of code, we’re thrilled to introduce <strong>Stac 1.0</strong> — the most complete version of Stac yet.</p><p>Here’s what’s new (and why it matters):</p><h3>Dart-to-JSON</h3><p>This was our most requested feature — and the one we’ve spent the most time perfecting. With <strong>Dart-to-JSON</strong>, you’ll never have to touch JSON again.<br>Write your UI directly in Dart, and Stac will automatically convert it to JSON.</p><p><strong>The result? </strong>Faster workflows, static analysis, fewer errors, and a much happier developer experience.</p><p>To know more, checkout our docs -&gt; <a href="https://docs.stac.dev/quickstart">https://docs.stac.dev/quickstart</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=twitter&amp;url=https%3A//x.com/divyanshub024/status/1974453850506686972&amp;image=" width="500" height="281" frameborder="0" scrolling="no"><a href="https://medium.com/media/0958e0ff7506823f30ae5d707c49613e/href">https://medium.com/media/0958e0ff7506823f30ae5d707c49613e/href</a></iframe><h3>Stac CLI</h3><p>The new <strong>Stac CLI</strong> is now your central hub for managing every aspect of your Stac projects — giving you <strong>end-to-end control</strong> directly from the terminal. Whether you’re scaffolding a new project, building screens, deploying updates, or inspecting logs, the CLI streamlines your workflow and reduces friction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwKqahnhe2UHCaOI19p9OA.png" /></figure><p>To know more about Stac CLI, checkout -&gt; <a href="https://docs.stac.dev/cli">https://docs.stac.dev/cli</a></p><h3>Stac Cloud &amp; Console</h3><p>One of the biggest hurdles of server-driven UI is setting up a server and hosting your screens. Mobile developers often end up acting as backend engineers or relying heavily on them, which slows down deployment cycles and creates friction.</p><p><strong>Stac Cloud</strong> solves this by providing a secure, fully managed backend for your server-driven UI. Deploy your JSON screens with a single command and your app updates are live globally — no hosting, storage, or infrastructure headaches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKulieuTZ937ywdketJg1Q.png" /></figure><p>The <a href="https://console.stac.dev/"><strong>Stac Console</strong></a> gives you a simple, visual interface to manage your projects and inspect your screens. Push updates with a click and see your app reflect changes immediately — dynamic UI updates without App Store approvals. It also empowers non-developers like PMs and designers to <strong>collaborate</strong>, <strong>experiment</strong>, and <strong>update</strong> screens directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rXrBAWXE8whc4lr75rtMzA.png" /></figure><p>Try out Stac Console now -&gt; <a href="https://console.stac.dev/">https://console.stac.dev/</a></p><h3>Framework Updates &amp; New Widgets</h3><p>Stac 1.0 is more than just a set of new widgets. It’s a complete framework upgrade that makes updating your apps faster, safer, and way more enjoyable.</p><h4><strong>Error Logging &amp; Handling</strong></h4><p>Debugging just got a glow-up. With StacError and StacErrorWidget, when something goes wrong, you actually know what’s happening. No more blank screens — instead, you get a clear, friendly error widget 🙂. Logging is cleaner, errors are easier to track, and your development workflow feels a lot less painful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*PXy2qzL2cgZvWwcOO2ggng.png" /></figure><h4>Widgets widgets widgets…</h4><p>On the widgets side, Stac 1.0 introduces a carefully selected set of powerful new components to cover common UI and interaction patterns:</p><ul><li><strong>Visual &amp; layout:</strong> ClipRRect, ClipOval, StacBackdropFilter</li><li><strong>Interactions:</strong> GestureDetector, InkWell</li><li><strong>Dynamic behavior:</strong> setValue, conditional, StacVisibility</li><li><strong>App structure &amp; feedback:</strong> Drawer, StacErrorWidget</li></ul><p>These widgets are fully compatible with Dart-to-JSON and the Stac workflow, making it easier than ever to create interactive, dynamic, and resilient UIs. Combined with the core framework improvements, these updates empower developers to iterate quickly, reduce boilerplate, and deliver polished, production-ready server-driven Flutter apps.</p><h4>Enhanced Theming and Styling</h4><p>We’ve also enhanced theming support, including Material 3 color variants, color transparency using @ notation, and new styling capabilities in StacText.</p><p>Full Changelogs -&gt; <a href="https://github.com/StacDev/stac/releases/tag/v1.0.0">https://github.com/StacDev/stac/releases/tag/v1.0.0</a></p><h3>Rebranding &amp; New Logo</h3><p>With 1.0, we are also giving Stac a refreshed look and feel. Our tech has evolved a lot since we started, and our designer didn’t want to be left behind :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*TrcFc0l3zPf83_wjZ7_gdA.png" /></figure><p>Our new logo represents the same principles that drive Stac itself: <strong>precision and speed</strong>. The converging lines build toward a sharp, defined core showcasing how Stac connects to every layer of your stack.</p><p>We are also shifting our design to signal the same maturity as our technology. Our new identity isn’t just an aesthetic upgrade; it’s a reflection of how far we have come and where we are heading: a platform that’s <strong>fast, reliable, and distinctly ours</strong>.</p><h3>What’s Next for Stac</h3><p>Stac 1.0 is just the beginning. We’ve laid the foundation with a solid framework, powerful widgets, and a seamless Cloud workflow — but there’s so much more ahead.</p><ul><li><strong>More Widgets &amp; Actions:</strong> We’re constantly expanding the library with new interactive components and dynamic actions, so you can build richer UIs without reinventing the wheel.</li><li><strong>Improved Developer Tools:</strong> Expect even smoother CLI commands, better error handling, and more ways to inspect, debug, and optimize your Stac projects.</li><li><strong>Community &amp; Contributions:</strong> We’d love to hear your thoughts, ideas, and suggestions. We’ll continue to grow documentation, examples, and tutorials, and we want developers like you to contribute and help shape the framework. Join the conversation on <a href="https://discord.com/invite/vTGsVRK86V">Discord</a> or share your contributions on <a href="https://github.com/StacDev/stac">GitHub</a>.</li><li><strong>Experimentation &amp; Fun:</strong> We’re exploring ways to make server-driven UIs even more dynamic and interactive — think creative animations, conditional logic, and smarter widgets that respond to your app’s state.</li></ul><p>Basically, if Stac 1.0 was the rocket launch, what’s coming next is the orbit. We can’t wait to see what you build, how you push the framework further, and the amazing apps you create.</p><h3>Users love Stac!</h3><p>The love and support we’ve received have been absolutely overwhelming. It’s an incredible feeling to see something you’ve built with so much care being embraced by so many.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*kDp8tfAc-aGEbeFKsETmLA.png" /></figure><p><strong>A Heartfelt Thank You to Our Community</strong></p><p>With over 368 commits and 75,000 lines of code, Stac 1.0 wouldn’t exist without all of you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bqOFVxw4z6KTnciCZX_o5g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00802abf5f6e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stac/introducing-stac-1-0-00802abf5f6e">Introducing Stac 1.0</a> was originally published in <a href="https://medium.com/stac">Stac</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Dynamic Forms in Flutter with Stac]]></title>
            <link>https://medium.com/stac/building-dynamic-forms-in-flutter-with-stac-ba724abc8a12?source=rss----86d4bb8ece39---4</link>
            <guid isPermaLink="false">https://medium.com/p/ba724abc8a12</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Divyanshu Bhargava]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 11:01:21 GMT</pubDate>
            <atom:updated>2025-04-02T11:01:21.134Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn how to create flexible, server-driven forms in Flutter that adapt to user needs in real-time using the Stac framework.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3XFlDOGUz3XMaaTbgL82dw.png" /><figcaption>Designed by <a href="https://x.com/byBisht">Rahul</a></figcaption></figure><p>Forms are an essential part of human interaction. Whether it’s filing a complaint, signing up for a new app, or completing a KYC process, forms have been deeply integrated into our daily lives. Since the early 19th century, they have evolved from paper-based documents to digital interfaces, becoming a fundamental component of modern applications.</p><p>Despite this evolution, most digital forms remain static — offering the same experience to every user. While this approach works for simple cases like login screens, it falls short in more complex scenarios like onboarding or KYC, where form fields should adapt based on user-specific factors. For instance, a KYC form might require different information depending on the user’s country or regulatory requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*LRF6eIjGA__0f4s7.jpg" /><figcaption>You could say… a form is always being <em>formed</em> 😄.</figcaption></figure><p>In this blog, we’ll explore how to build dynamic forms using <a href="https://github.com/StacDev/stac"><strong>Stac</strong></a>, a powerful framework that enables flexible, server-driven UI. By leveraging Stac, you can create forms that adapt to user needs in real-time, delivering a more personalized and seamless experience. Let’s dive in!</p><h4><strong>Prerequisites</strong></h4><p>✅ <strong>Stac Setup</strong> — If you haven’t set up Stac yet, head over to the <a href="https://stac.dev/"><strong>official website</strong></a> and check out the <a href="https://medium.com/stac/introducing-mirai-a-server-driven-ui-framework-for-flutter-d020fd0c387d"><strong>intro blog</strong></a> for a step-by-step guide.</p><h3><strong>🛠️ </strong>Creating the form UI</h3><p>In this guide, we’ll build a user registration screen that collects user details, calls an API to create a new user, and triggers an action based on whether the API call succeeds or fails. Here’s what our example screen looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*FnoyAIqKIdDEMtdH6DBw0Q.png" /></figure><p>To begin, let’s create a basic scaffold screen with a form widget. As we saw in our intro <a href="https://medium.com/stac/introducing-mirai-a-server-driven-ui-framework-for-flutter-d020fd0c387d">blog</a>, the structure of Stac JSON closely follows Flutter’s widget tree.</p><pre>{<br>    &quot;type&quot;: &quot;scaffold&quot;,<br>    &quot;backgroundColor&quot;: &quot;#F4F6FA&quot;,<br>    &quot;appBar&quot;: {<br>        &quot;type&quot;: &quot;appBar&quot;,<br>        &quot;backgroundColor&quot;: &quot;transparent&quot;<br>    },<br>    &quot;body&quot;: {<br>        &quot;type&quot;: &quot;form&quot;,<br>        &quot;child&quot;: {<br>            &quot;type&quot;: &quot;padding&quot;,<br>            &quot;padding&quot;: {<br>                &quot;left&quot;: 24,<br>                &quot;right&quot;: 24<br>            },<br>            &quot;child&quot;: {<br>                &quot;type&quot;: &quot;column&quot;,<br>                &quot;crossAxisAlignment&quot;: &quot;start&quot;,<br>                &quot;children&quot;: []<br>            }<br>        }<br>    }<br>}</pre><blockquote>💡 <strong>Note:</strong> Wrapping the input fields inside a form widget is crucial — it allows you to validate fields and retrieve their values when submitting the form.</blockquote><p>Now that our basic structure is ready, let’s add text fields and an action button.</p><p><strong>Adding Input Fields</strong></p><p>The basic text form field structure in Stac JSON looks like this.</p><pre> {<br>  &quot;type&quot;: &quot;textFormField&quot;,<br>  &quot;id&quot;: &quot;firstName&quot;,<br>  &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>  &quot;validatorRules&quot;: [<br>    {<br>      &quot;rule&quot;: &quot;isName&quot;,<br>      &quot;message&quot;: &quot;Please enter your first name&quot;<br>    }<br>  ],<br>  &quot;style&quot;: {<br>    &quot;fontSize&quot;: 16,<br>    &quot;fontWeight&quot;: &quot;w400&quot;,<br>    &quot;height&quot;: 1.5<br>  },<br>  &quot;decoration&quot;: {<br>    &quot;hintText&quot;: &quot;First Name&quot;,<br>    &quot;filled&quot;: true,<br>    &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>    &quot;border&quot;: {<br>      &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>      &quot;borderRadius&quot;: 8,<br>      &quot;color&quot;: &quot;#24151D29&quot;<br>    }<br>  }<br>}</pre><p>🔑 There are <strong>three key properties</strong> in this JSON:</p><ul><li><strong>type</strong> — Specifies the widget type (textFormField in this case).</li><li><strong>id</strong> — Used to retrieve the field’s value when submitting the form.</li><li><strong>validatorRules</strong> — Defines validation rules. You can use regex or built-in <a href="https://github.com/StacDev/stac/blob/dev/packages/stac/lib/src/utils/input_validations.dart">validators</a>.</li></ul><h4><strong>Building the Complete Form</strong></h4><p>Now, let’s add all required input fields along with a <strong>Submit</strong> button.</p><pre>{<br>    &quot;type&quot;: &quot;scaffold&quot;,<br>    &quot;backgroundColor&quot;: &quot;#F4F6FA&quot;,<br>    &quot;appBar&quot;: {<br>        &quot;type&quot;: &quot;appBar&quot;,<br>        &quot;backgroundColor&quot;: &quot;transparent&quot;<br>    },<br>    &quot;body&quot;: {<br>        &quot;type&quot;: &quot;form&quot;,<br>        &quot;child&quot;: {<br>            &quot;type&quot;: &quot;padding&quot;,<br>            &quot;padding&quot;: {<br>                &quot;left&quot;: 24,<br>                &quot;right&quot;: 24<br>            },<br>            &quot;child&quot;: {<br>                &quot;type&quot;: &quot;column&quot;,<br>                &quot;crossAxisAlignment&quot;: &quot;start&quot;,<br>                &quot;children&quot;: [<br>                    {<br>                        &quot;type&quot;: &quot;text&quot;,<br>                        &quot;data&quot;: &quot;Create User&quot;,<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 24,<br>                            &quot;fontWeight&quot;: &quot;w700&quot;,<br>                            &quot;height&quot;: 1.3<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 24<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;firstName&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;isName&quot;,<br>                                &quot;message&quot;: &quot;Please enter your first name&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;First Name&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;lastName&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;isName&quot;,<br>                                &quot;message&quot;: &quot;Please enter your last name&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;Last Name&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;email&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;isEmail&quot;,<br>                                &quot;message&quot;: &quot;Please enter a valid email&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;Email&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;phoneNumber&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;^(\\+\\d{1,2}\\s?)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$&quot;,<br>                                &quot;message&quot;: &quot;Please enter a valid phone number&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;Phone Number&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 32<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;filledButton&quot;,<br>                        &quot;style&quot;: {<br>                            &quot;backgroundColor&quot;: &quot;#151D29&quot;,<br>                            &quot;shape&quot;: {<br>                                &quot;borderRadius&quot;: 8<br>                            }<br>                        },<br>                        &quot;onPressed&quot;: {},<br>                        &quot;child&quot;: {<br>                            &quot;type&quot;: &quot;padding&quot;,<br>                            &quot;padding&quot;: {<br>                                &quot;top&quot;: 14,<br>                                &quot;bottom&quot;: 14,<br>                                &quot;left&quot;: 16,<br>                                &quot;right&quot;: 16<br>                            },<br>                            &quot;child&quot;: {<br>                                &quot;type&quot;: &quot;row&quot;,<br>                                &quot;mainAxisAlignment&quot;: &quot;spaceBetween&quot;,<br>                                &quot;children&quot;: [<br>                                    {<br>                                        &quot;type&quot;: &quot;text&quot;,<br>                                        &quot;data&quot;: &quot;Create User&quot;<br>                                    },<br>                                    {<br>                                        &quot;type&quot;: &quot;icon&quot;,<br>                                        &quot;iconType&quot;: &quot;material&quot;,<br>                                        &quot;icon&quot;: &quot;arrow_forward&quot;<br>                                    }<br>                                ]<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;align&quot;,<br>                        &quot;alignment&quot;: &quot;center&quot;,<br>                        &quot;child&quot;: {<br>                            &quot;type&quot;: &quot;text&quot;,<br>                            &quot;data&quot;: &quot;User information will be stored securely&quot;,<br>                            &quot;textAlign&quot;: &quot;center&quot;,<br>                            &quot;style&quot;: {<br>                                &quot;fontSize&quot;: 15,<br>                                &quot;fontWeight&quot;: &quot;w400&quot;,<br>                                &quot;color&quot;: &quot;#000000&quot;<br>                            }<br>                        }<br>                    }<br>                ]<br>            }<br>        }<br>    }<br>}</pre><p>Here is our form screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*DuO6BJd6bOaitjbNSCfOxw.png" /></figure><p><strong>Instantly Update Forms</strong></p><p>With Stac’s <strong>server-driven</strong> nature, you can modify the form on the fly without redeploying the app. For example, let’s add a phone number field:</p><pre>{<br>  &quot;type&quot;: &quot;textFormField&quot;,<br>  &quot;id&quot;: &quot;phoneNumber&quot;,<br>  &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>  &quot;validatorRules&quot;: [<br>    {<br>      &quot;rule&quot;: &quot;^(\\+\\d{1,2}\\s?)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$&quot;,<br>      &quot;message&quot;: &quot;Please enter a valid phone number&quot;<br>    }<br>  ],<br>  &quot;style&quot;: {<br>    &quot;fontSize&quot;: 16,<br>    &quot;fontWeight&quot;: &quot;w400&quot;,<br>    &quot;height&quot;: 1.5<br>  },<br>  &quot;decoration&quot;: {<br>    &quot;hintText&quot;: &quot;Phone Number&quot;,<br>    &quot;filled&quot;: true,<br>    &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>    &quot;border&quot;: {<br>      &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>      &quot;borderRadius&quot;: 8,<br>      &quot;color&quot;: &quot;#24151D29&quot;<br>    }<br>  }<br>}</pre><p>Once this JSON is updated, the new field will instantly appear in the app — no need to push an app update. 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*YHjObX4T3U0ZpybfDWZCaA.png" /></figure><p>Now that our form is fully functional, we can proceed to handle API calls and user actions.</p><h3><strong>✅ Validating the Form</strong></h3><p>Form validation in <strong>Stac</strong> is easy! Just follow these two simple steps:</p><ol><li><strong>Define Validation Rules</strong></li></ol><p>Specify validation rules for your fields to ensure users enter the correct information.</p><pre>{<br>  &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>  &quot;validatorRules&quot;: [<br>    {<br>      &quot;rule&quot;: &quot;isName&quot;,<br>      &quot;message&quot;: &quot;Please enter your first name&quot;<br>    }<br>  ]<br>}</pre><p>This ensures that the field is validated as the user types, prompting them if the input doesn’t match the expected format.</p><p><strong>2. Trigger Validation</strong></p><p>When the form is submitted, call the validateForm action to check if the input is valid.</p><pre>  {<br>  &quot;onPressed&quot;: {<br>    &quot;actionType&quot;: &quot;validateForm&quot;,<br>    &quot;isValid&quot;: {},<br>    &quot;isNotValid&quot;: {}<br>  }<br>}</pre><p>The validateForm action provides two key callbacks:</p><p>• <strong>isValid</strong> → Called when all fields pass validation ✅</p><p>• <strong>isNotValid</strong> → Called when there’s an error ❌</p><p>With just these two steps, you ensure users enter the right information before proceeding. No more incomplete forms slipping through! 🚀</p><h3><strong>🚀 Submitting the Form</strong></h3><p>Now that our form is validated, it’s time to submit it and call our API. For this example, we’ll use the <strong>dummy JSON Add User </strong><a href="https://dummyjson.com/docs/users#users-add"><strong>API</strong></a>.</p><p>In <strong>Stac</strong>, API calls are handled using the networkRequest action. Just like any other network request, you’ll provide the <strong>URL, method, headers, and body</strong>. But here’s the cool part — <strong>we don’t hardcode the body values</strong>. Instead, we use the getFormValue action to dynamically fetch values from form fields.</p><blockquote>📝 <strong>Note:</strong> The id in getFormValue must match exactly with the id of the textFormField to fetch the correct values.</blockquote><p><strong>📤 Making the API Call</strong></p><p>Here’s how we submit the form and send user details to the API:</p><pre>{<br>  &quot;onPressed&quot;: {<br>    &quot;actionType&quot;: &quot;validateForm&quot;,<br>    &quot;isValid&quot;: {<br>      &quot;actionType&quot;: &quot;networkRequest&quot;,<br>      &quot;url&quot;: &quot;https://dummyjson.com/users/add&quot;,<br>      &quot;method&quot;: &quot;post&quot;,<br>      &quot;headers&quot;: {<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>      },<br>      &quot;body&quot;: {<br>        &quot;firstName&quot;: {<br>          &quot;actionType&quot;: &quot;getFormValue&quot;,<br>          &quot;id&quot;: &quot;firstName&quot;<br>        },<br>        &quot;lastName&quot;: {<br>          &quot;actionType&quot;: &quot;getFormValue&quot;,<br>          &quot;id&quot;: &quot;lastName&quot;<br>        },<br>        &quot;email&quot;: {<br>          &quot;actionType&quot;: &quot;getFormValue&quot;,<br>          &quot;id&quot;: &quot;email&quot;<br>        },<br>        &quot;phoneNumber&quot;: {<br>          &quot;actionType&quot;: &quot;getFormValue&quot;,<br>          &quot;id&quot;: &quot;phoneNumber&quot;<br>        }<br>      }<br>    }<br>  }<br>}</pre><h3><strong>🎯 Handling API Responses</strong></h3><p><strong>Stac</strong> makes it easy to <strong>listen to API responses</strong> and trigger actions based on the status code returned. This means you can <strong>show success messages or handle errors seamlessly</strong>.</p><p><strong>✅ Defining API Response Actions</strong></p><p>Here’s how we handle different API responses:</p><pre>{<br>  &quot;results&quot;: [<br>    {<br>      &quot;statusCode&quot;: 201,<br>      &quot;action&quot;: {<br>        &quot;actionType&quot;: &quot;showDialog&quot;,<br>        &quot;widget&quot;: {<br>          &quot;type&quot;: &quot;alertDialog&quot;,<br>          &quot;title&quot;: {<br>            &quot;type&quot;: &quot;text&quot;,<br>            &quot;data&quot;: &quot;Successful&quot;<br>          }<br>        }<br>      }<br>    },<br>    {<br>      &quot;statusCode&quot;: 400,<br>      &quot;action&quot;: {<br>        &quot;actionType&quot;: &quot;showDialog&quot;,<br>        &quot;widget&quot;: {<br>          &quot;type&quot;: &quot;alertDialog&quot;,<br>          &quot;title&quot;: {<br>            &quot;type&quot;: &quot;text&quot;,<br>            &quot;data&quot;: &quot;Error&quot;<br>          }<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p><strong>🎉 And That’s It!<br></strong>With just a <strong>few steps</strong>, we’ve built a fully functional, <strong>dynamic form</strong> that submits data and handles responses — <strong>without touching native code!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*6crizL7hJe8RkzDeClgk2g.gif" /></figure><p>Next time you need to <strong>add or update fields</strong>, you don’t have to go through the hassle of modifying app logic — just tweak the <strong>JSON</strong> and your app updates instantly! 🎯</p><p>Here is the final JSON.</p><pre>{<br>    &quot;type&quot;: &quot;scaffold&quot;,<br>    &quot;backgroundColor&quot;: &quot;#F4F6FA&quot;,<br>    &quot;appBar&quot;: {<br>        &quot;type&quot;: &quot;appBar&quot;,<br>        &quot;backgroundColor&quot;: &quot;transparent&quot;<br>    },<br>    &quot;body&quot;: {<br>        &quot;type&quot;: &quot;form&quot;,<br>        &quot;child&quot;: {<br>            &quot;type&quot;: &quot;padding&quot;,<br>            &quot;padding&quot;: {<br>                &quot;left&quot;: 24,<br>                &quot;right&quot;: 24<br>            },<br>            &quot;child&quot;: {<br>                &quot;type&quot;: &quot;column&quot;,<br>                &quot;crossAxisAlignment&quot;: &quot;start&quot;,<br>                &quot;children&quot;: [<br>                    {<br>                        &quot;type&quot;: &quot;text&quot;,<br>                        &quot;data&quot;: &quot;Create User&quot;,<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 24,<br>                            &quot;fontWeight&quot;: &quot;w700&quot;,<br>                            &quot;height&quot;: 1.3<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 24<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;firstName&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;isName&quot;,<br>                                &quot;message&quot;: &quot;Please enter your first name&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;First Name&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;lastName&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;isName&quot;,<br>                                &quot;message&quot;: &quot;Please enter your last name&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;Last Name&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;email&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;isEmail&quot;,<br>                                &quot;message&quot;: &quot;Please enter a valid email&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;Email&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;textFormField&quot;,<br>                        &quot;id&quot;: &quot;phoneNumber&quot;,<br>                        &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>                        &quot;validatorRules&quot;: [<br>                            {<br>                                &quot;rule&quot;: &quot;^(\\+\\d{1,2}\\s?)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$&quot;,<br>                                &quot;message&quot;: &quot;Please enter a valid phone number&quot;<br>                            }<br>                        ],<br>                        &quot;style&quot;: {<br>                            &quot;fontSize&quot;: 16,<br>                            &quot;fontWeight&quot;: &quot;w400&quot;,<br>                            &quot;height&quot;: 1.5<br>                        },<br>                        &quot;decoration&quot;: {<br>                            &quot;hintText&quot;: &quot;Phone Number&quot;,<br>                            &quot;filled&quot;: true,<br>                            &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>                            &quot;border&quot;: {<br>                                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                                &quot;borderRadius&quot;: 8,<br>                                &quot;color&quot;: &quot;#24151D29&quot;<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 32<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;filledButton&quot;,<br>                        &quot;style&quot;: {<br>                            &quot;backgroundColor&quot;: &quot;#151D29&quot;,<br>                            &quot;shape&quot;: {<br>                                &quot;borderRadius&quot;: 8<br>                            }<br>                        },<br>                        &quot;onPressed&quot;: {<br>                            &quot;actionType&quot;: &quot;validateForm&quot;,<br>                            &quot;isValid&quot;: {<br>                                &quot;actionType&quot;: &quot;networkRequest&quot;,<br>                                &quot;url&quot;: &quot;https://dummyjson.com/users/add&quot;,<br>                                &quot;method&quot;: &quot;post&quot;,<br>                                &quot;headers&quot;: {<br>                                    &quot;Content-Type&quot;: &quot;application/json&quot;<br>                                },<br>                                &quot;body&quot;: {<br>                                    &quot;firstName&quot;: {<br>                                        &quot;actionType&quot;: &quot;getFormValue&quot;,<br>                                        &quot;id&quot;: &quot;firstName&quot;<br>                                    },<br>                                    &quot;lastName&quot;: {<br>                                        &quot;actionType&quot;: &quot;getFormValue&quot;,<br>                                        &quot;id&quot;: &quot;lastName&quot;<br>                                    },<br>                                    &quot;email&quot;: {<br>                                        &quot;actionType&quot;: &quot;getFormValue&quot;,<br>                                        &quot;id&quot;: &quot;email&quot;<br>                                    },<br>                                    &quot;phoneNumber&quot;: {<br>                                        &quot;actionType&quot;: &quot;getFormValue&quot;,<br>                                        &quot;id&quot;: &quot;phoneNumber&quot;<br>                                    }<br>                                },<br>                                &quot;results&quot;: [<br>                                    {<br>                                        &quot;statusCode&quot;: 201,<br>                                        &quot;action&quot;: {<br>                                            &quot;actionType&quot;: &quot;showDialog&quot;,<br>                                            &quot;widget&quot;: {<br>                                                &quot;type&quot;: &quot;alertDialog&quot;,<br>                                                &quot;title&quot;: {<br>                                                    &quot;type&quot;: &quot;text&quot;,<br>                                                    &quot;data&quot;: &quot;Successful&quot;<br>                                                }<br>                                            }<br>                                        }<br>                                    },<br>                                    {<br>                                        &quot;statusCode&quot;: 400,<br>                                        &quot;action&quot;: {<br>                                            &quot;actionType&quot;: &quot;showDialog&quot;,<br>                                            &quot;widget&quot;: {<br>                                                &quot;type&quot;: &quot;alertDialog&quot;,<br>                                                &quot;title&quot;: {<br>                                                    &quot;type&quot;: &quot;text&quot;,<br>                                                    &quot;data&quot;: &quot;Error&quot;<br>                                                }<br>                                            }<br>                                        }<br>                                    }<br>                                ]<br>                            }<br>                        },<br>                        &quot;child&quot;: {<br>                            &quot;type&quot;: &quot;padding&quot;,<br>                            &quot;padding&quot;: {<br>                                &quot;top&quot;: 14,<br>                                &quot;bottom&quot;: 14,<br>                                &quot;left&quot;: 16,<br>                                &quot;right&quot;: 16<br>                            },<br>                            &quot;child&quot;: {<br>                                &quot;type&quot;: &quot;row&quot;,<br>                                &quot;mainAxisAlignment&quot;: &quot;spaceBetween&quot;,<br>                                &quot;children&quot;: [<br>                                    {<br>                                        &quot;type&quot;: &quot;text&quot;,<br>                                        &quot;data&quot;: &quot;Create User&quot;<br>                                    },<br>                                    {<br>                                        &quot;type&quot;: &quot;icon&quot;,<br>                                        &quot;iconType&quot;: &quot;material&quot;,<br>                                        &quot;icon&quot;: &quot;arrow_forward&quot;<br>                                    }<br>                                ]<br>                            }<br>                        }<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;sizedBox&quot;,<br>                        &quot;height&quot;: 16<br>                    },<br>                    {<br>                        &quot;type&quot;: &quot;align&quot;,<br>                        &quot;alignment&quot;: &quot;center&quot;,<br>                        &quot;child&quot;: {<br>                            &quot;type&quot;: &quot;text&quot;,<br>                            &quot;data&quot;: &quot;User information will be stored securely&quot;,<br>                            &quot;textAlign&quot;: &quot;center&quot;,<br>                            &quot;style&quot;: {<br>                                &quot;fontSize&quot;: 15,<br>                                &quot;fontWeight&quot;: &quot;w400&quot;,<br>                                &quot;color&quot;: &quot;#000000&quot;<br>                            }<br>                        }<br>                    }<br>                ]<br>            }<br>        }<br>    }<br>}</pre><p><em>main.dart</em></p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:stac/stac.dart&#39;;<br><br>void main() async {<br>  await Stac.initialize();<br><br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Stac Dynamic Form&#39;,<br>      home: Stac.fromAssets(&#39;assets/json/create_user.json&#39;),<br>    );<br>  }<br>}</pre><h3>Thank you for reading 👋</h3><p>I hope you enjoyed this article. If you have any queries or suggestions please let me know in the comments below.</p><p>You can connect with me on <a href="https://twitter.com/divyanshub024">Twitter</a>, <a href="https://github.com/divyanshub024">Github</a>, and <a href="https://www.linkedin.com/in/divyanshub024/">LinkedIn</a>. You can subscribe to my newsletter to get an email notification for my latest articles.</p><p>🚀 Want to explore more about <strong>Stac</strong>? Check out:<br><strong>🔗 Website:</strong> <a href="https://stac.dev/">stac.dev</a><br><strong>💻 GitHub:</strong> <a href="https://github.com/buildstac">github.com/</a>StacDev/Stac</p><p>Happy Coding… See you next time 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba724abc8a12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stac/building-dynamic-forms-in-flutter-with-stac-ba724abc8a12">Building Dynamic Forms in Flutter with Stac</a> was originally published in <a href="https://medium.com/stac">Stac</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Custom Widgets & Actions in Stac]]></title>
            <link>https://medium.com/stac/building-custom-widgets-actions-in-stac-da2e0dae1dff?source=rss----86d4bb8ece39---4</link>
            <guid isPermaLink="false">https://medium.com/p/da2e0dae1dff</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Divyanshu Bhargava]]></dc:creator>
            <pubDate>Fri, 07 Feb 2025 14:12:59 GMT</pubDate>
            <atom:updated>2025-02-07T14:12:59.335Z</atom:updated>
            <content:encoded><![CDATA[<h4>Mastering Server-Driven UI Customization in Stac</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qedOC-fauPtneuIbjeopJQ.png" /><figcaption>Design by <a href="https://x.com/byBisht">Rahul Bisht</a></figcaption></figure><p>In our last <a href="https://medium.com/buildmirai/introducing-mirai-a-server-driven-ui-framework-for-flutter-d020fd0c387d">blog</a>, we explore how Server-Driven UI frameworks like <a href="https://stac.dev/">Stac</a> empower developers to dynamically create, update, and manage app interfaces without pushing frequent code updates. While Stac provides a robust set of out-of-the-box <a href="https://docs.stac.dev/category/stac-widgets">widgets</a> and <a href="https://docs.stac.dev/category/stac-actions">actions</a> to kickstart development, there are scenarios where you may need to implement custom widgets or actions to cater to specific business requirements or add unique features.</p><p>In this blog, we’ll explore the process of building custom widgets and actions in Stac, enabling you to extend its functionality and tailor it to your application’s needs.</p><h3>Why Build Custom Widgets and Actions?</h3><p>Stac’s standard library includes a variety of widgets like buttons, text, containers, and actions such as navigation or API calls. However, there are instances when you might require:</p><ul><li><strong>Custom design elements</strong> that align with your brand’s identity.</li><li><strong>Integration with proprietary APIs</strong> or third-party libraries.</li><li><strong>Unique user interactions</strong> that are not covered by default widgets.</li><li><strong>Optimized components</strong> for specific use cases.</li></ul><p>Creating custom widgets and actions allows you to maintain flexibility while keeping the power of server-driven UI intact.</p><h3>Let’s Build a Counter App (SDUI Style!)</h3><p>We’ll take a simple counter app and make it server-driven, controlling its UI and behavior from the backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*DL3Da-TZeHASZNdQoJLRww.png" /></figure><h3>Building Custom Widget</h3><h4>Step 1: Define the widget schema</h4><p>The widget schema defines the structure of the custom widget. This schema is used to parse data from the server, including the properties you want to control dynamically from the server.</p><p>First, let’s create counter_screen.dart, where we&#39;ll define the structure for our counter app.</p><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;<br><br>part &#39;counter_screen.freezed.dart&#39;;<br>part &#39;counter_screen.g.dart&#39;;<br><br>@freezed<br>class CounterScreen with _$CounterScreen {<br>  const factory CounterScreen({<br>    required String title,<br>    required String description,<br>    @Default(0) int initialCount,<br>    Map&lt;String, dynamic&gt;? onIncrement,<br>    Map&lt;String, dynamic&gt;? onDecrement,<br>  }) = _CounterScreen;<br><br>  factory CounterScreen.fromJson(Map&lt;String, dynamic&gt; json) =&gt;<br>      _$CounterScreenFromJson(json);<br>}</pre><blockquote><strong>Note:</strong> We’re using freezed to generate our data classes, but feel free to use any approach that works best for you.</blockquote><p>Now that our data class is ready let’s build our widget parser class.</p><h4>Step 2: Create the widget parser</h4><p>To create a custom widget parser, we’ll create CounterScreenParser, which extends StacParser&lt;CounterScreen&gt;. This abstract class provides three essential methods:</p><ul><li>type: Identifies the widget type in the JSON object.</li><li>getModel: Parses the JSON data into a Dart object.</li><li>parse: Builds the custom widget using the provided model.</li></ul><pre>import &#39;package:counter_example/counter/widgets/counter_screen.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:stac/stac.dart&#39;;<br><br>class CounterScreenParser extends StacParser&lt;CounterScreen&gt; {<br>  const CounterScreenParser();<br><br>  @override<br>  String get type =&gt; &#39;counterScreen&#39;;<br><br>  @override<br>  CounterScreen getModel(Map&lt;String, dynamic&gt; json) =&gt;<br>      CounterScreen.fromJson(json);<br><br>  @override<br>  Widget parse(BuildContext context, CounterScreen model) {<br>    return Scaffold(...);<br>  }<br>}</pre><p>As you can see, we’ve set the type to “counterScreen” and defined getModel as CounterScreen.fromJson(json). Now, let’s implement the widget in the parse method.</p><pre>  @override<br>  Widget parse(BuildContext context, CounterScreen model) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(model.title),<br>      ),<br>      body: Center(<br>        child: Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: [<br>            Text(model.description),<br>            Text(<br>              model.initialCount.toString(),<br>              style: Theme.of(context).textTheme.headlineMedium,<br>            ),<br>          ],<br>        ),<br>      ),<br>      floatingActionButton: Row(<br>        mainAxisSize: MainAxisSize.min,<br>        children: [<br>          FloatingActionButton(<br>            onPressed: () {},<br>            tooltip: &#39;Decrement&#39;,<br>            child: const Icon(Icons.remove),<br>          ),<br>          SizedBox(width: 12),<br>          FloatingActionButton(<br>            onPressed: () {},<br>            tooltip: &#39;Increment&#39;,<br>            child: const Icon(Icons.add),<br>          ),<br>        ],<br>      ),<br>    );<br>  }</pre><p>As you can see, it’s the familiar Flutter counter app screen, but instead of hardcoded values in the Text widget, we’re using model.title, model.description, and model.initialCount.</p><h4>Step 3: Register the CounterScreenParser</h4><p>Finally, you need to register the custom parser with Stac so that it can be used to interpret JSON objects. You can register the parser when initializing Stac by passing it in the parsers parameter.</p><pre>void main() async {<br>  await Stac.initialize(<br>    parsers: [<br>      CounterScreenParser(),<br>    ],<br>  );<br><br>  runApp(const MyApp());<br>}</pre><p>That’s it. And finally, our JSON to render the CounterScreen will look like this.</p><pre>{<br>  &quot;type&quot;: &quot;counterScreen&quot;,<br>  &quot;title&quot;: &quot;Stac Counter Example&quot;,<br>  &quot;description&quot;: &quot;You have pushed the button this many times:&quot;,<br>  &quot;initialCount&quot;: 110<br>}</pre><p>To render the JSON into a widget use <em>Stac.fromJson </em>method. To know other ways to render check out our last <a href="https://medium.com/p/d020fd0c387d">blog</a> post. Finally, our main.dart will look like this.</p><pre>import &#39;package:counter_example/counter/widgets/counter_screen_parser.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:stac/stac.dart&#39;;<br><br>void main() async {<br>  await Stac.initialize(<br>    parsers: [<br>      CounterScreenParser(),<br>    ],<br>  );<br><br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Stac Counter Example&#39;,<br>      theme: ThemeData(<br>        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),<br>        useMaterial3: true,<br>      ),<br>      home: Stac.fromJson(json, context) ?? SizedBox(),<br>    );<br>  }<br>}</pre><p>Our Server-Driven UI counter app is ready. But guess what nothing happens when we click on the buttons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6w5TIPuek3wtDIMr9OsoQ.gif" /></figure><p>Let’s dive into implementing a Custom Action that includes custom business logic and interacts with the widget’s state.</p><h3>Building Custom Actions</h3><p>Building custom actions is quite similar to building custom widgets.</p><h4>Step 1: Define the Action Schema</h4><p>Let’s create counter_action.dart to define the action structure.</p><pre>import &#39;package:freezed_annotation/freezed_annotation.dart&#39;;<br><br>part &#39;counter_action.freezed.dart&#39;;<br>part &#39;counter_action.g.dart&#39;;<br><br>enum CounterActionType {<br>  increment,<br>  decrement,<br>}<br><br>@freezed<br>class CounterAction with _$CounterAction {<br>  const factory CounterAction({<br>    required CounterActionType counterActionType,<br>    @Default(1) int delta,<br>  }) = _CounterAction;<br><br>  factory CounterAction.fromJson(Map&lt;String, dynamic&gt; json) =&gt;<br>      _$CounterActionFromJson(json);<br>}</pre><h4><strong>Step 2: Create the action parser.</strong></h4><p>To create a custom action parser let’s create a CounterActionParser class that extends StacActionParser&lt;CounterAction&gt;. Just like StacParser, StacActionParser is an abstract class that provides 3 methods.</p><ol><li>actionType<strong>:</strong> Takes a string used to identify the type of the action in the JSON object.</li><li>getModel<strong>: </strong>Takes a fromJson method to parse the JSON data to the dart object.</li><li>onCall<strong>:</strong> The onCall method lets you define your custom action using the provided model.</li></ol><pre>import &#39;dart:async&#39;;<br><br>import &#39;package:counter_example/counter/cubit/counter_cubit.dart&#39;;<br>import &#39;package:flutter/src/widgets/framework.dart&#39;;<br>import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;<br>import &#39;package:stac/stac.dart&#39;;<br><br>import &#39;counter_action.dart&#39;;<br><br>class CounterActionParser extends StacActionParser&lt;CounterAction&gt; {<br>  const CounterActionParser();<br><br>  @override<br>  String get actionType =&gt; &#39;counterAction&#39;;<br><br>  @override<br>  CounterAction getModel(Map&lt;String, dynamic&gt; json) =&gt;<br>      CounterAction.fromJson(json);<br><br>  @override<br>  FutureOr onCall(BuildContext context, CounterAction model) {<br>    switch (model.counterActionType) {<br>      case CounterActionType.increment:<br>        context.read&lt;CounterCubit&gt;().increment(model.delta);<br>        break;<br>      case CounterActionType.decrement:<br>        context.read&lt;CounterCubit&gt;().decrement(model.delta);<br>        break;<br>    }<br>  }<br>}</pre><p>In this action, depending upon the counterActionType we are calling the CounterCubit to either increment or decrement the counter.</p><p>Here is what thecounter_cubit.dart looks like.</p><pre>import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;<br><br>class CounterCubit extends Cubit&lt;int&gt; {<br>  CounterCubit(int? initialCount) : super(initialCount ?? 0);<br><br>  void increment(int value) =&gt; emit(state + value);<br>  void decrement(int value) =&gt; emit(state - value);<br>}</pre><p>Now, let’s wrap our Counter Text widget with BlocBuilder so it updates the count on button click.</p><pre>                  BlocBuilder&lt;CounterCubit, int&gt;(<br>                    builder: (context, count) =&gt; Text(<br>                      &#39;$count&#39;,<br>                      style: Theme.of(context).textTheme.headlineMedium,<br>                    ),<br>                  ),</pre><p>To trigger a StacAction on button click, use the Stac.onCallFromJson method. Here&#39;s the updated code for our Floating Action Buttons:</p><pre>FloatingActionButton(<br>  onPressed: () =&gt; Stac.onCallFromJson(model.onDecrement, context),<br>  // ...<br>),<br>FloatingActionButton(<br>  onPressed: () =&gt; Stac.onCallFromJson(model.onIncrement, context),<br>  // ...<br>),</pre><p>Finally here is what our counter_screen_parser looks like.</p><pre>import &#39;package:counter_example/counter/cubit/counter_cubit.dart&#39;;<br>import &#39;package:counter_example/counter/widgets/counter_screen.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_bloc/flutter_bloc.dart&#39;;<br>import &#39;package:stac/stac.dart&#39;;<br><br>class CounterScreenParser extends StacParser&lt;CounterScreen&gt; {<br>  const CounterScreenParser();<br><br>  @override<br>  String get type =&gt; &#39;counterScreen&#39;;<br><br>  @override<br>  CounterScreen getModel(Map&lt;String, dynamic&gt; json) =&gt;<br>      CounterScreen.fromJson(json);<br><br>  @override<br>  Widget parse(BuildContext context, CounterScreen model) {<br>    return BlocProvider(<br>      create: (_) =&gt; CounterCubit(model.initialCount),<br>      child: Builder(<br>        builder: (context) {<br>          return Scaffold(<br>            appBar: AppBar(<br>              title: Text(model.title),<br>            ),<br>            body: Center(<br>              child: Column(<br>                mainAxisAlignment: MainAxisAlignment.center,<br>                children: [<br>                  Text(model.description),<br>                  BlocBuilder&lt;CounterCubit, int&gt;(<br>                    builder: (context, count) =&gt; Text(<br>                      &#39;$count&#39;,<br>                      style: Theme.of(context).textTheme.headlineMedium,<br>                    ),<br>                  ),<br>                ],<br>              ),<br>            ),<br>            floatingActionButton: Row(<br>              mainAxisSize: MainAxisSize.min,<br>              children: [<br>                FloatingActionButton(<br>                  onPressed: () =&gt;<br>                      Stac.onCallFromJson(model.onDecrement, context),<br>                  tooltip: &#39;Decrement&#39;,<br>                  child: const Icon(Icons.remove),<br>                ),<br>                SizedBox(width: 12),<br>                FloatingActionButton(<br>                  onPressed: () =&gt;<br>                      Stac.onCallFromJson(model.onIncrement, context),<br>                  tooltip: &#39;Increment&#39;,<br>                  child: const Icon(Icons.add),<br>                ),<br>              ],<br>            ),<br>          );<br>        },<br>      ),<br>    );<br>  }<br>}</pre><h4>Step 3: Register the CounterActionParser</h4><p>Finally, we need to register theCounterActionParser in Stac initialize, by passing it in the actionParsers parameter.</p><pre>void main() async {<br>  await Stac.initialize(<br>    parsers: [CounterScreenParser()],<br>    actionParsers: [CounterActionParser()],<br>  );<br><br>  runApp(const MyApp());<br>}</pre><p>That’s it. Here’s the JSON structure to render the CounterScreen.</p><pre>{<br>  &quot;type&quot;: &quot;counterScreen&quot;,<br>  &quot;title&quot;: &quot;Stac Counter Example&quot;,<br>  &quot;description&quot;: &quot;You have pushed the button this many times:&quot;,<br>  &quot;onIncrement&quot;: {<br>    &quot;actionType&quot;: &quot;counterAction&quot;,<br>    &quot;counterActionType&quot;: &quot;increment&quot;,<br>    &quot;delta&quot;: 1,<br>  },<br>  &quot;onDecrement&quot;: {<br>    &quot;actionType&quot;: &quot;counterAction&quot;,<br>    &quot;counterActionType&quot;: &quot;decrement&quot;,<br>    &quot;delta&quot;: 2,<br>  }<br>}</pre><p>If you take a closer look, you’ll see that the counter increases by 1 but decreases by 2 as defined in our delta.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1ZPPO4BJu4Q%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1ZPPO4BJu4Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1ZPPO4BJu4Q%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5dc53373d2805978ec2f5393db980933/href">https://medium.com/media/5dc53373d2805978ec2f5393db980933/href</a></iframe><p>“Explore the complete source code here 👇</p><p><a href="https://github.com/StacDev/stac/tree/dev/examples/counter_example">stac/examples/counter_example at dev · StacDev/stac</a></p><h3>Conclusion</h3><p>Custom widgets and actions are at the heart of <a href="https://stac.dev/">Stac’s</a> powerful server-driven UI framework, giving you the flexibility and efficiency to build truly dynamic applications. Ready to experience it firsthand? Explore the Stac ecosystem: browse the <a href="https://stac.dev/">Stac</a> framework on <a href="https://github.com/StacDev/stac">GitHub</a>, get started with our detailed <a href="https://docs.stac.dev/">docs</a>, and experiment with live UIs in the <a href="https://playground.stac.dev/">Stac Playground</a>. We’re excited to see what you create! Stay tuned for more in-depth blog posts covering advanced features, best practices, and real-world use cases.</p><h3>Thank you for reading 👋</h3><p>I hope you enjoyed this article. If you have any queries or suggestions please let me know in the comments down below.</p><p>You can connect with me on <a href="https://twitter.com/divyanshub024">Twitter</a>, <a href="https://github.com/divyanshub024">Github</a>, and <a href="https://www.linkedin.com/in/divyanshub024/">LinkedIn</a>. You can subscribe to my newsletter to get an email notification for my latest articles.</p><p>Happy Coding… See you next time 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da2e0dae1dff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stac/building-custom-widgets-actions-in-stac-da2e0dae1dff">Building Custom Widgets &amp; Actions in Stac</a> was originally published in <a href="https://medium.com/stac">Stac</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Introducing Stac — A Server Driven UI framework for Flutter]]></title>
            <link>https://medium.com/stac/introducing-mirai-a-server-driven-ui-framework-for-flutter-d020fd0c387d?source=rss----86d4bb8ece39---4</link>
            <guid isPermaLink="false">https://medium.com/p/d020fd0c387d</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Divyanshu Bhargava]]></dc:creator>
            <pubDate>Mon, 27 Jan 2025 17:52:55 GMT</pubDate>
            <atom:updated>2025-03-29T17:32:55.648Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Introducing Stac — A Server Driven UI framework for Flutter</h3><h4>Build dynamic UIs and push app updates in seconds with JSON</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*48cSdpp0Kp3ymtrJhjcuuQ.png" /><figcaption>Design by <a href="https://x.com/byBisht">Rahul Bisht</a></figcaption></figure><p>Mobile apps have existed for quite a long time since the launch of AppStore and PlayStore in 2008, until today when there are millions of apps out there. But in this time frame, it’s not only the number of apps that have changed. Apps have become much more <strong>dynamic</strong>, <strong>personalized</strong>, and <strong>smart</strong>.</p><p>Yet, one thing hasn’t changed: <strong>how we publish mobile apps.</strong></p><p>It’s still the same tedious process. You push updates to the store, wait for approval (sometimes praying it doesn’t get stuck in review limbo), and then hope users actually bother to update their app. Oh, and if there’s a bug? Welcome to emergency patch territory. <em>sigh</em> 😮‍💨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*EaWorkoWqEF60A8ER5DWXA.png" /></figure><p>What if you could escape the tedious app update cycle entirely? Imagine sending updates on the fly and steering the UI directly from the server — no delays, no approvals. That’s exactly what <strong>Server-Driven UI</strong> is all about.</p><p>To understand Server-Driven UI, let’s first talk about the traditional approach, i.e. <strong>Client-Driven UI</strong>.</p><h3><strong>What is Client-Driven UI?</strong></h3><p>In the traditional <strong>Client-Driven UI</strong> approach, the app’s UI is tightly coupled with its codebase. Essentially, the client (your app) handles everything — UI layouts, business logic, and rendering. Want to change how a button looks or add a new feature? You’ll need to update the app’s code, test it, and then push the update to the app stores. And then comes the waiting game: store approvals followed by users actually updating their apps. Sound familiar? <em>Yeah, it’s exhausting.</em></p><p>While this approach works, it has some glaring limitations:</p><ul><li><strong>Slow Update Cycles:</strong> Even minor UI tweaks require a full update process.</li><li><strong>Scalability Issues:</strong> Managing multiple platforms becomes a headache as each app has its own codebase.</li><li><strong>Lack of Flexibility:</strong> Changes aren’t instantaneous — you’re at the mercy of app store approvals and user behavior.</li></ul><h3>What is Server-Driven UI (SDUI)?</h3><p><strong>Server-Driven UI (SDUI)</strong> is a paradigm where the server drives the UI, rather than the UI being hardcoded in the app itself. Instead of the client app determining what to render, it primarily focuses on <strong>how</strong> to render the components defined by the server.</p><p>Think of it like a browser rendering a website. Your browser doesn’t know ahead of time what content it’s going to display — it just knows how to interpret and render &lt;HTML&gt; tags. Similarly, in SDUI, the app is equipped to render widgets or components sent by the server, making the UI dynamic, flexible, and completely server-controlled.</p><p>Here’s how does Server-Driven UI works:</p><ol><li>The server defines the app’s UI (typically in a lightweight format like JSON).</li><li>The client (your app) receives these definitions and renders the UI dynamically.</li><li>Any changes to the UI? Just update the server, and the app instantly reflects them — no app updates required!</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BsIaUpWBkjLrfWxZhsc-wg.png" /></figure><p>But building Server-Driven UI is <strong>hard</strong> — you need to support countless Flutter widgets, manage complex navigation, handle network calls, and efficiently manage state, all while ensuring seamless compatibility and top-notch performance. That’s exactly where <strong>Stac</strong> saves the day.</p><h3>Introducing Stac 🚀</h3><p>Meet <strong>Stac (</strong>formerly Mirai<strong>)</strong>, the powerful <strong>Server-Driven UI (SDUI)</strong> framework built specifically for Flutter. With Stac, you can build stunning, cross-platform applications dynamically, using <strong>JSON</strong> to define your UI in real time.</p><p><a href="https://github.com/StacDev/stac">GitHub - StacDev/stac: Stac (formerly Mirai) is a Server-Driven UI (SDUI) framework for Flutter, enabling you to create stunning, cross-platform applications dynamically with JSON. Build and update your app&#39;s UI in real-time with ease and flexibility!</a></p><h3>Installing Stac</h3><p>To get started with Stac, follow the installation instructions below:</p><ol><li><strong>Add the </strong>Stac<strong> dependency to your </strong><strong>pubspec.yaml file:</strong></li></ol><p>Run the following command:</p><pre>flutter pub add stac</pre><p>This will add Stac to your package’s pubspec.yaml (and run an implicit flutter pub get):</p><p>Alternatively, you can manually add the dependency to your app from within your pubspec.yaml:</p><pre>dependencies:<br>  stac: ^&lt;latest-version&gt;</pre><p><strong>2. Run the following command in your terminal to install the package:</strong></p><pre>flutter pub get</pre><p><strong>3. Import the Stac package in your Dart file:</strong></p><pre>import &#39;package:stac/stac.dart&#39;;</pre><p>Now, you’re ready to start using Stac in your Flutter project.</p><h3>Initializing Stac</h3><p>In the main function, initialize Stac to set up the necessary configurations, and prepare your app for rendering UI from JSON.</p><pre>void main() async {<br>  await Stac.initialize();<br>  runApp(const MyApp());<br>}</pre><p>That’s it. Now that your app is SDUI packed you can use Stac.fromJson(), Stac.fromAsset() or Stac.fromNetwork() method to render UI.</p><h3>Defining Stac JSONs</h3><p>Stac JSONs are designed to feel familiar, especially if you’ve worked with Flutter’s widget structure. In fact, Stac JSONs are essentially the JSON equivalent of Flutter widgets — they mirror the same hierarchy and logic, just in a different format.</p><p>Here’s the magic: if you can write a Flutter widget tree, you can easily define a Stac JSON. Let’s compare:</p><h4>Flutter Widget:</h4><pre>Column(<br>  children: [<br>    Text(&quot;Hello, Stac!&quot;),<br>    ElevatedButton(<br>      onPressed: () =&gt; print(&quot;Button Pressed&quot;),<br>      child: Text(&quot;Click Me&quot;),<br>    ),<br>  ],<br>)</pre><h4>Stac<strong> JSON Equivalent:</strong></h4><pre>{<br>  &quot;type&quot;: &quot;column&quot;,<br>  &quot;children&quot;: [<br>    {<br>      &quot;type&quot;: &quot;text&quot;,<br>      &quot;data&quot;: &quot;Hello, Stac!&quot;<br>    },<br>    {<br>      &quot;type&quot;: &quot;elevatedButton&quot;,<br>      &quot;onPressed&quot;: {<br>          &quot;action&quot;: &quot;print&quot;,<br>          &quot;message&quot;: &quot;Button Pressed&quot;<br>        },<br>        &quot;child&quot;: {<br>          &quot;type&quot;: &quot;text&quot;,<br>          &quot;data&quot;: &quot;Click Me&quot;<br>        }<br>    }<br>  ]<br>}</pre><p>See the resemblance? It’s like translating your Flutter widgets into JSON. The structure remains intuitive, so you’re not learning a whole new paradigm — you’re just writing Flutter in JSON form.</p><h3>Key Benefits of Stac</h3><ol><li><strong>Instant UI Updates: </strong>Skip the hassle of app updates and store approvals. With SDUI, changes made on the server go live instantly, ensuring your app stays up-to-date at all times.</li><li><strong>Personalization Made Easy: </strong>Deliver unique, tailored experiences to users by serving different UIs based on preferences, behaviors, or demographics — all without touching client-side code.</li><li><strong>Simplified Maintenance: </strong>Manage your UI logic centrally on the server. This reduces the complexity of maintaining multiple app versions and keeps updates consistent across platforms.</li><li><strong>Effortless A/B Testing: </strong>Experiment with multiple UI versions in real-time by serving variant payloads directly from the server. Gain insights and iterate faster without additional development cycles.</li><li><strong>Reduced Development Overhead: </strong>Focus your efforts on backend logic while the server handles UI updates. This minimizes client-side development, making your workflow faster and more efficient.</li></ol><h3>Form screen example with Stac</h3><p>Let’s see Stac in action by building a simple <strong>Sign-In Screen</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*EjTnKZJirgTve6MIVdF-Cw.png" /></figure><h4><strong>Server-Side JSON Definition</strong></h4><p>Here’s how the server defines the Sign-In screen in Stac JSON:</p><pre>{<br><br>  &quot;type&quot;: &quot;scaffold&quot;,<br>  &quot;backgroundColor&quot;: &quot;#F4F6FA&quot;,<br>  &quot;appBar&quot;: {<br>    &quot;type&quot;: &quot;appBar&quot;,<br>    &quot;backgroundColor&quot;: &quot;#00FFFFFF&quot;,<br>  },<br>  &quot;body&quot;: {<br>    &quot;type&quot;: &quot;form&quot;,<br>    &quot;child&quot;: {<br>      &quot;type&quot;: &quot;padding&quot;,<br>      &quot;padding&quot;: {&quot;left&quot;: 24, &quot;right&quot;: 24},<br>      &quot;child&quot;: {<br>        &quot;type&quot;: &quot;column&quot;,<br>        &quot;crossAxisAlignment&quot;: &quot;start&quot;,<br>        &quot;children&quot;: [<br>          {<br>            &quot;type&quot;: &quot;text&quot;,<br>            &quot;data&quot;: &quot;Sign in&quot;,<br>            &quot;style&quot;: {&quot;fontSize&quot;: 24, &quot;fontWeight&quot;: &quot;w800&quot;, &quot;height&quot;: 1.3}<br>          },<br>          {&quot;type&quot;: &quot;sizedBox&quot;, &quot;height&quot;: 24},<br>          {<br>            &quot;type&quot;: &quot;textFormField&quot;,<br>            &quot;id&quot;: &quot;email&quot;,<br>            &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>            &quot;validatorRules&quot;: [<br>              {&quot;rule&quot;: &quot;isEmail&quot;, &quot;message&quot;: &quot;Please enter a valid email&quot;}<br>            ],<br>            &quot;style&quot;: {&quot;fontSize&quot;: 16, &quot;fontWeight&quot;: &quot;w400&quot;, &quot;height&quot;: 1.5},<br>            &quot;decoration&quot;: {<br>              &quot;hintText&quot;: &quot;Email&quot;,<br>              &quot;filled&quot;: true,<br>              &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>              &quot;border&quot;: {<br>                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                &quot;borderRadius&quot;: 8,<br>                &quot;color&quot;: &quot;#24151D29&quot;<br>              }<br>            }<br>          },<br>          {&quot;type&quot;: &quot;sizedBox&quot;, &quot;height&quot;: 16},<br>          {<br>            &quot;type&quot;: &quot;textFormField&quot;,<br>            &quot;autovalidateMode&quot;: &quot;onUserInteraction&quot;,<br>            &quot;validatorRules&quot;: [<br>              {&quot;rule&quot;: &quot;isPassword&quot;, &quot;message&quot;: &quot;Please enter a valid password&quot;}<br>            ],<br>            &quot;obscureText&quot;: true,<br>            &quot;maxLines&quot;: 1,<br>            &quot;style&quot;: {&quot;fontSize&quot;: 16, &quot;fontWeight&quot;: &quot;w400&quot;, &quot;height&quot;: 1.5},<br>            &quot;decoration&quot;: {<br>              &quot;hintText&quot;: &quot;Password&quot;,<br>              &quot;filled&quot;: true,<br>              &quot;fillColor&quot;: &quot;#FFFFFF&quot;,<br>              &quot;border&quot;: {<br>                &quot;type&quot;: &quot;outlineInputBorder&quot;,<br>                &quot;borderRadius&quot;: 8,<br>                &quot;color&quot;: &quot;#24151D29&quot;<br>              }<br>            }<br>          },<br>          {&quot;type&quot;: &quot;sizedBox&quot;, &quot;height&quot;: 32},<br>          {<br>            &quot;type&quot;: &quot;filledButton&quot;,<br>            &quot;style&quot;: {<br>              &quot;backgroundColor&quot;: &quot;#151D29&quot;,<br>              &quot;shape&quot;: {&quot;borderRadius&quot;: 8}<br>            },<br>            &quot;onPressed&quot;: {<br>              &quot;actionType&quot;: &quot;none&quot;,<br>            },<br>            &quot;child&quot;: {<br>              &quot;type&quot;: &quot;padding&quot;,<br>              &quot;padding&quot;: {&quot;top&quot;: 14, &quot;bottom&quot;: 14, &quot;left&quot;: 16, &quot;right&quot;: 16},<br>              &quot;child&quot;: {<br>                &quot;type&quot;: &quot;row&quot;,<br>                &quot;mainAxisAlignment&quot;: &quot;spaceBetween&quot;,<br>                &quot;children&quot;: [<br>                  {&quot;type&quot;: &quot;text&quot;, &quot;data&quot;: &quot;Proceed&quot;},<br>                  {<br>                    &quot;type&quot;: &quot;icon&quot;,<br>                    &quot;iconType&quot;: &quot;material&quot;,<br>                    &quot;icon&quot;: &quot;arrow_forward&quot;<br>                  }<br>                ]<br>              }<br>            }<br>          },<br>          {&quot;type&quot;: &quot;sizedBox&quot;, &quot;height&quot;: 16},<br>          {<br>            &quot;type&quot;: &quot;align&quot;,<br>            &quot;alignment&quot;: &quot;center&quot;,<br>            &quot;child&quot;: {<br>              &quot;type&quot;: &quot;textButton&quot;,<br>              &quot;onPressed&quot;: {<br>                &quot;actionType&quot;: &quot;none&quot;,<br>              },<br>              &quot;child&quot;: {<br>                &quot;type&quot;: &quot;text&quot;,<br>                &quot;data&quot;: &quot;Forgot password?&quot;,<br>                &quot;style&quot;: {<br>                  &quot;fontSize&quot;: 15,<br>                  &quot;fontWeight&quot;: &quot;w500&quot;,<br>                  &quot;color&quot;: &quot;#4745B4&quot;<br>                }<br>              }<br>            }<br>          },<br>          {&quot;type&quot;: &quot;sizedBox&quot;, &quot;height&quot;: 8},<br>          {<br>            &quot;type&quot;: &quot;align&quot;,<br>            &quot;alignment&quot;: &quot;center&quot;,<br>            &quot;child&quot;: {<br>              &quot;type&quot;: &quot;text&quot;,<br>              &quot;data&quot;: &quot;Don&#39;t have an account? &quot;,<br>              &quot;style&quot;: {<br>                &quot;fontSize&quot;: 15,<br>                &quot;fontWeight&quot;: &quot;w400&quot;,<br>                &quot;color&quot;: &quot;#000000&quot;<br>              },<br>              &quot;children&quot;: [<br>                {<br>                  &quot;data&quot;: &quot;Sign Up for BettrDo&quot;,<br>                  &quot;style&quot;: {<br>                    &quot;fontSize&quot;: 15,<br>                    &quot;fontWeight&quot;: &quot;w500&quot;,<br>                    &quot;color&quot;: &quot;#4745B4&quot;<br>                  }<br>                }<br>              ]<br>            }<br>          }<br>        ]<br>      }<br>    }<br>  }<br>}</pre><h4><strong>Client-Side Implementation</strong></h4><p>Here’s how to render the server-defined UI on the client side using Stac.fromNetwork method.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:stac/stac.dart&#39;;<br><br>void main() async {<br>  await Stac.initialize();<br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Stac App&#39;,<br>      theme: ThemeData(),<br>      home: Stac.fromNetwork(<br>        request: StacNetworkRequest(<br>          url: &#39;https://example.com/ui.json&#39;,<br>        ),<br>        context: context,<br>      ),<br>    );<br>  }<br>}</pre><p>With just a few lines of code and a JSON definition, you’ve got a dynamic sign-in screen powered by Stac. It’s that simple! 🚀</p><h3><strong>What’s Next?</strong></h3><p>Ready to explore Stac? Head over to our <a href="https://github.com/StacDev/stac">GitHub</a> to dive into the code, check out our detailed <a href="https://docs.buildmirai.dev/">docs</a> to get started, and experiment with dynamic UIs in real-time using the <a href="https://playground.buildmirai.dev/">Stac Playground</a>. It’s everything you need to build smarter, faster, and better apps with Stac!</p><p>Stay tuned for more in-depth blogs on Stac, where we’ll explore advanced features, best practices, and real-world examples to help you unlock its full potential! 🌟</p><h4><strong>Next Articles in this Series</strong></h4><ul><li><a href="https://medium.com/stac/building-custom-widgets-actions-in-stac-da2e0dae1dff">Building Custom Widgets &amp; Actions in Stac</a></li></ul><h3>Thank you for reading 👋</h3><p>I hope you enjoyed this article. If you have any queries or suggestions please let me know in the comments down below.</p><p>You can connect with me on <a href="https://twitter.com/divyanshub024">Twitter</a>, <a href="https://github.com/divyanshub024">Github</a>, and <a href="https://www.linkedin.com/in/divyanshub024/">LinkedIn</a>. You can subscribe to my newsletter to get an email notification for my latest articles.</p><p>Happy Coding… See you next time 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d020fd0c387d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stac/introducing-mirai-a-server-driven-ui-framework-for-flutter-d020fd0c387d">🚀 Introducing Stac — A Server Driven UI framework for Flutter</a> was originally published in <a href="https://medium.com/stac">Stac</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>