<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andi on Medium]]></title>
        <description><![CDATA[Stories by Andi on Medium]]></description>
        <link>https://medium.com/@uncoded-decimal?source=rss-5b4f618d314d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jR-gyku5HEo6vChwTBnsjw.jpeg</url>
            <title>Stories by Andi on Medium</title>
            <link>https://medium.com/@uncoded-decimal?source=rss-5b4f618d314d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 10:37:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@uncoded-decimal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Jaspr: Styling for Dummies]]></title>
            <link>https://uncoded-decimal.medium.com/jaspr-styling-for-dummies-5e3971778cc0?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e3971778cc0</guid>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[jaspr]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 23:31:01 GMT</pubDate>
            <atom:updated>2026-10-24T23:31:01.366Z</atom:updated>
            <content:encoded><![CDATA[<p>We added some HTML elements to our web site last time using just Dart. In this article, we will work on making it look like more than just something a fifth grader put together.</p><p><em>Again, not a substitute for the actual documentation </em><a href="https://docs.jaspr.site/concepts/styling"><em>here</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDgyut0mSJJ0AMuVIM9pOw.png" /></figure><p>There’s a few ways to style your website:</p><ol><li><strong>Stylesheets</strong><br>If you’ve worked on web with other frameworks before, you’re already familiar with this. You add a CSS file to your document, define CSS-style classes in it and use these classes to style your components.<br><em>(For the sake of this article, I’ll not cover this.)</em></li><li><strong>Inline Styles</strong><br>As a Flutter developer, this would be the most familiar method of defining an element’s style while writing the element.<br><em>(Here’s where we’ll start.)</em></li><li><strong>Component Styles</strong><br>Jaspr docs recommend using the static@css getter styles to separate the style class definitions. This would be a great way to localise the component style code while maintaing readability.<br><em>(Here’s where we’ll get to.)</em></li></ol><p>Here’s where we start:</p><figure><img alt="starting point for this article with 2 buttons and the associated HTML displayed" src="https://cdn-images-1.medium.com/max/1024/1*BypdywCEBhzwuAI2Q8Hjkg.png" /><figcaption>Just the components displayed</figcaption></figure><p>Let’s make this a column layout using inline styles.</p><pre>    return div(<br>      styles: Styles(<br>        display: Display.flex,<br>        flexDirection: FlexDirection.column,<br>        gap: Gap(row: Unit.points(10)),<br>      ),<br>      [<br>        CounterButton(),<br>        SunnyComponent(),<br>      ],<br>    );</pre><p>Here: <br>1. Display.flex marks the div to behave as a FlexBox <em>(</em><a href="https://www.w3schools.com/css/css3_flexbox.asp"><em>Read here</em></a><em>).<br></em>2. FlexDirection.column marks the direction in which to lay it’s children.<br>3. Use gap to define the space between the two elements. row in Gap marks the space between the rows of a column. (<a href="https://www.w3schools.com/css/css_units.asp"><em>Read about CSS units here</em></a><em>.</em>)</p><p>Similarly, let’s style our CounterButton.</p><figure><img alt="Counter button styled with inline style html displayed" src="https://cdn-images-1.medium.com/max/1024/1*g7MDf46mDZutk44Ky7O7GQ.png" /><figcaption>Counter button with inline HTML style</figcaption></figure><pre>      styles: Styles(<br>        padding: Spacing.symmetric(horizontal: Unit.em(2), vertical: Unit.em(0.5)),<br>        margin: Spacing.all(Unit.em(1.5)),<br>        border: Border.all(color: Colors.white, style: BorderStyle.double),<br>        radius: BorderRadius.circular(Unit.em(1.2)),<br>        alignContent: AlignContent.center,<br>        color: Colors.white,<br>        backgroundColor: Colors.darkCyan,<br>      ),</pre><p>Now, let’s generate the CounterButton style using the component getter styles . <br>Here’s the code:</p><pre>class CounterButtonState extends State&lt;CounterButton&gt; {<br>  int count = 0;<br><br>  @override<br>  Component build(BuildContext context) {<br>    return button(<br>      classes: &#39;counter&#39;,<br>      ...<br>    );<br>  }<br><br>  @css<br>  static List&lt;StyleRule&gt; get styles =&gt; [<br>    css(&#39;.counter&#39;).styles(<br>      padding: Spacing.symmetric(horizontal: Unit.em(2), vertical: Unit.em(0.5)),<br>      margin: Spacing.all(Unit.em(1.5)),<br>      border: Border.all(color: Colors.white, style: BorderStyle.double),<br>      radius: BorderRadius.circular(Unit.em(1.2)),<br>      alignContent: AlignContent.center,<br>      color: Colors.white,<br>      backgroundColor: Colors.darkCyan,<br>    ),<br>  ];<br>}</pre><blockquote><strong>Note 1:</strong> Make sure the State class is public otherwise it won’t recognise styles as a utilised getter and no styles would render.</blockquote><blockquote><strong>Note 2:</strong> The name can be re-used to apply the same styling to any other component within the app. Be sure to use component specific names to avoid mixing up.</blockquote><p>About nested styles:</p><pre>  @css<br>  static List&lt;StyleRule&gt; get styles =&gt; [<br>    css(&#39;.counter&#39;, [<br>      css(&#39;&amp;&#39;).styles(<br>        padding: Spacing.symmetric(horizontal: Unit.em(2), vertical: Unit.em(0.5)),<br>        margin: Spacing.all(Unit.em(1.5)),<br>        border: Border.all(color: Colors.white, style: BorderStyle.double),<br>        radius: BorderRadius.circular(Unit.em(1.2)),<br>        alignContent: AlignContent.center,<br>        color: Colors.white,<br>        backgroundColor: Colors.darkCyan,<br>      ),<br>      css(&#39;b&#39;).styles(<br>        color: Colors.yellow,<br>        fontSize: Unit.percent(120),<br>      ),<br>    ]),<br>  ];</pre><p>Here:<br>1. .counter marks the style class name under which the other styles would apply.<br>2. &amp; targets the element marked with the parent class counter .<br>3. b target all the b text elements inside the element marked with class counter .</p><p>Now, for the SunnyComponent , let’s add some state based animations. Adding animations is not possible using Inline styles. We need to be able to target button states and some other style parameters to be able to define animating values.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1235336097%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1235336097%3Ffl%3Dtl%26fe%3Dec&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2211554492-4918503f2fc7e60ed420ffe734376260f0b8cbc779743492279b4cac47dab6eb-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/e70e1cf577f58a30f25f059c7c967ae0/href">https://medium.com/media/e70e1cf577f58a30f25f059c7c967ae0/href</a></iframe><p>Here’s the code that goes into building this:</p><pre>  @override<br>  Component build(BuildContext context) {<br>    return button(<br>      classes: [<br>        &#39;sunny_button&#39;,<br>        if (isSunny &amp;&amp; !isLoading) &#39;sunny&#39;,<br>        if (!isSunny &amp;&amp; !isLoading) &#39;not_sunny&#39;,<br>        if (isLoading) &#39;sunny_loading&#39;,<br>      ].join(&#39; &#39;),<br>      events: {<br>        &#39;click&#39;: (_) async {<br>          setState(() {<br>            isLoading = true;<br>          });<br>          isSunny = await _observerWeather();<br>          setState(() {<br>            isLoading = false;<br>          });<br>        },<br>      },<br>      isLoading ? [.text(&#39;Loading&#39;)] : [.text(isSunny ? &#39;Must be sunny&#39; : &#39;No sun&#39;)],<br>    );<br>  }<br><br>  @css<br>  static List&lt;StyleRule&gt; get styles =&gt; [<br>    css(<br>      &#39;.sunny_button&#39;,<br>      [<br>        css(&#39;&amp;&#39;).styles(<br>          padding: Spacing.symmetric(vertical: Unit.em(0.5), horizontal: Unit.em(1.2)),<br>          margin: Spacing.symmetric(horizontal: Unit.em(1.4)),<br>          radius: BorderRadius.only(<br>            topRight: Radius.circular(Unit.pixels(16)),<br>            bottomRight: Radius.circular(Unit.pixels(4)),<br>            bottomLeft: Radius.circular(Unit.pixels(16)),<br>          ),<br>          shadow: BoxShadow(<br>            offsetX: Unit.pixels(2),<br>            offsetY: Unit.pixels(5),<br>            spread: Unit.pixels(1.2),<br>            color: Colors.lightGrey.withOpacity(0.3),<br>          ),<br>          transition: Transition.combine(<br>            [<br>              Transition(&#39;font-size&#39;, duration: const Duration(milliseconds: 300)),<br>              Transition(&#39;background-color&#39;, duration: const Duration(milliseconds: 300)),<br>            ],<br>          ),<br>          backgroundColor: Colors.beige,<br>        ),<br>        css(&#39;&amp;:hover&#39;).styles(<br>          transform: Transform.scale(1.03),<br>          fontSize: Unit.percent(102),<br>          backgroundColor: Colors.beige.withOpacity(0.5),<br>        ),<br>        css(&#39;&amp;.sunny_loading&#39;).styles(<br>          transform: Transform.scale(0.98),<br>          fontSize: Unit.percent(70),<br>          backgroundColor: Colors.white,<br>        ),<br>        css(&#39;&amp;.sunny_loading:hover&#39;).styles(<br>          transform: Transform.scale(0.98),<br>          fontSize: Unit.percent(70),<br>          backgroundColor: Colors.white,<br>        ),<br>        css(&#39;&amp;.sunny&#39;).styles(<br>          color: Colors.coral,<br>          backgroundColor: Colors.lightYellow,<br>        ),<br>        css(&#39;&amp;.not_sunny&#39;).styles(<br>          color: Colors.ghostWhite,<br>          backgroundColor: Colors.darkGray,<br>        ),<br>      ],<br>    ),<br>  ];</pre><p>Here:<br>1. Since, classes takes just a String, we add all the classes with a blank space as a separator.<br>2. hover helps define the style when the button is in the state hover .<br>3. &amp;.sunny_loading:hover selects the button style class of loading and applies the hover state style selecctively.<br>4. transition param helps define individually how long each style param takes to animate between values of button style classes and button states.</p><p><em>Sigh…</em></p><p>So much code for just 2 buttons. Flutter just has state handlers. Even so, knowing the patterns of styling changes a lot about a component.</p><p>Inline styles are for getting started and for values that change at runtime. They can’t express component states like hoverat all, so the moment you need states and animation, @css will be what you want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*zydovu8dmh-lqkEtPtXh9w@2x.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e3971778cc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jaspr: Component Catalog]]></title>
            <link>https://uncoded-decimal.medium.com/jaspr-component-catalog-01bc3c885802?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/01bc3c885802</guid>
            <category><![CDATA[jaspr-component-catalog]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[jaspr]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 08:24:58 GMT</pubDate>
            <atom:updated>2026-10-24T08:24:58.484Z</atom:updated>
            <content:encoded><![CDATA[<p>The Flutter Widget Catalog was my starting point, I decided to build a Jaspr Component Catalog.</p><p>Jaspr documents do share a list of <a href="https://docs.jaspr.site/concepts/components#foundation-components">Foundational Components</a> but they aren’t as useful unless you know what you’re doing.</p><blockquote>Unlike Flutter, HTML elements accept multiple children by default.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oNlkJT6bz3wNU3SUYxJKg@2x.png" /></figure><h3>Text</h3><h4>Component.text()</h4><p>Or, the shorthand .text() literally just inserts the text into the HTML.</p><blockquote><strong><em>Note:</em></strong> This element <strong>can</strong> end up messing with the neighbour elements’ HTML. You can try this by adding a “example” randomly somewhere in your rendered HTML.</blockquote><h4><strong>Commonly used elements</strong></h4><p>HTML elements like the p , i , b , s , etc. These elements can be paired to render text with mixed styles. This is what we use RichText widget for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lkueSSo5kVKnfTVAy1yGaQ.png" /></figure><pre>        .text(&#39;text 1&#39;),<br>        p([.text(&#39;p text&#39;)]),<br>        b([.text(&#39;b text&#39;)]),<br>        i([<br>          .text(&#39;i text&#39;),<br>          p([.text(&#39;i p text&#39;)]), # don&#39;t nest `p` inside, this works because the browser handles the error<br>        ]),</pre><h4>Heading elements</h4><p>These are the standard h1 , h2 , h3 , h4 , h5 and h6 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_womNcdzJr012OOTy96qA.png" /></figure><pre>        h1([.text(&#39;h1&#39;)]),<br>        h2([.text(&#39;h2&#39;)]),<br>        h3([.text(&#39;h3&#39;)]),<br>        h4([.text(&#39;h4&#39;)]),<br>        h5([.text(&#39;h5&#39;)]),<br>        h6([.text(&#39;h6&#39;)]),</pre><h3>Clickable Elements</h3><h4>Link element</h4><p>We can use the HTML a element, or Jaspr’s Link element and wrap any of the HTML elements in them. Link is primarily for client-side routing.</p><h4>Button</h4><p>HTML has it’s own button element to help add interactivity. Unlike Flutter, we add our own styles for buttons to build the like of FlatButton, TextButton, ElevatedButton, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6kt8KTs7wCZLpRDCYcJrg.png" /></figure><pre><br>        Link(<br>          to: &#39;&#39;,<br>          child: .text(&#39;Here\&#39;s a Link&#39;),<br>        ),<br>        a(<br>          href: &#39;&#39;,<br>          [<br>            p([<br>              .text(&#39;Here\&#39;s the &#39;),<br>              b([.text(&#39;`a`&#39;)]),<br>              .text(&#39; element &#39;),<br>            ]),<br>          ],<br>        ),<br>        button(<br>          onClick: () {},<br>          [<br>            .text(&quot;Here&#39;s a button&quot;),<br>          ],<br>        ),</pre><h4>DOM events</h4><p>For more ways to customise interactivity, we can find the list of available <a href="https://developer.mozilla.org/en-US/docs/Web/API/UI_Events">DOM events</a>. This will help with building interactions offered through the GestureDetector .<br>For example, you can recognise a double-click through the event dblclick .</p><h3>Organising Elements</h3><h4>Grouping Components</h4><p>We can use div and the Component.fragment() to group multiple children.</p><p>A div expands to fit window width and allows for multiple children. We can then manipulate the flex properties to build a Column or Row layout.</p><p>A fragment wraps multiple children without creating another element wrapping them as div does.</p><h4>Lists</h4><p>We can use the HTML elements:<br>1. ul for unordered lists<br>2. ol for ordered lists</p><p>List items are built using li and can group other HTML elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YM16pcJOKBpi9jDg57WeMw.png" /></figure><pre><br>        ul([<br>          .text(&#39;ul text&#39;),<br>          li([<br>            b([.text(&#39;ul li b text&#39;)]),<br>          ]),<br>          li([<br>            a(href: &#39;&#39;, [.text(&#39;ul li a text&#39;)]),<br>            Link(to: &#39;&#39;, child: .text(&#39;ul li Link text&#39;)),<br>          ]),<br>        ]),<br>        ol([<br>          li([.text(&#39;ordered list item&#39;)]),<br>          li([<br>            button(<br>              onClick: () {},<br>              [.text(&#39;button&#39;)],<br>            ),<br>          ]),<br>        ]),</pre><h3>Media Elements</h3><p>We can always use the native HTML elements img , audio and video for rendering media elements.</p><p>img can also be used to render vector images. You will need to look up platform support guides to understand what the client browser supports.</p><p>For anything that isn’t either of these three, you’re allowed to use an iframe element or the embed elements.</p><h3>Custom Elements</h3><p>If we come across any custom built elements, or the elements that Jaspr doesn’t recognise but may be present in HTML, use the Component.element() to render them.</p><p>This is a foundational component and you can read about it <a href="https://docs.jaspr.site/concepts/components#componentelement">here</a>.</p><p>There’s tons of HTML elements and the listed in this article are just the starting point. You can start browsing <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements">MDN docs</a> and find the elements that fit into your needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*zydovu8dmh-lqkEtPtXh9w@2x.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01bc3c885802" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jaspr: For Dummies like me]]></title>
            <link>https://uncoded-decimal.medium.com/jaspr-for-dummies-like-me-deb90f13aa34?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/deb90f13aa34</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[jaspr]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 07:35:04 GMT</pubDate>
            <atom:updated>2026-10-22T07:35:46.005Z</atom:updated>
            <content:encoded><![CDATA[<p>Flutter on Web just draws on the HTML Canvas. If you need to build web<em>sites </em>with the actual HTML Elements, you want Jaspr.</p><p>If you’re a Flutter developer, you need to get ready for this huge new push. You will need to know the basics of Web development and the HTML elements that will build up your DOM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QDgyut0mSJJ0AMuVIM9pOw.png" /></figure><h4>Why? What’s the difference?</h4><p>The browser platform is so very different from the environment on which your Flutter app lives.</p><ul><li>Non interactivity is the default.</li><li>Styling lives outside the elements, by default.</li><li>The widget building itself will be so alien.</li></ul><p>Let’s get started with the base new Jaspr project.</p><h3>The Component System</h3><p>If you’re just getting started with Jaspr, you’ve probably read how there’s the StatelessComponent , the StatefulComponent and the InheritedComponent .</p><p>But this is just the base.</p><p>If you’re deploying your work on the server, you can also use the AsyncStatelessComponent and the StatefulComponent with PreloadStateMixin . This will also make the knowledge of @client and @sync crucial.</p><h4>Let me explain…</h4><p>A <a href="https://docs.jaspr.site/concepts/components#statelesscomponent">StatelessComponent</a> has:</p><ul><li>No mutable state</li><li>No Interactivity</li><li>Is SEO friendly</li></ul><p>Here’s an example of a StatelessComponent :</p><pre>class Widget1 extends StatelessComponent {<br>  @override<br>  Component build(BuildContext context) {<br>    return .text(&#39;Default widget&#39;); // component shorthand for text<br>  }<br>}</pre><p>A <a href="https://docs.jaspr.site/concepts/components#statefulcomponent">StatefulComponent</a> has:</p><ul><li>Mutable State</li><li>No Interactivity</li><li>Is SEO friendly</li></ul><p>Here’s an example of a StatefulComponent :</p><pre><br>class Widget2 extends StatefulComponent {<br>  const Widget2({super.key});<br>  @override<br>  State&lt;Widget2&gt; createState() =&gt; _Widget2State();<br>}<br><br>class _Widget2State extends State&lt;Widget2&gt; {<br>  int count = 0;<br>  @override<br>  Component build(BuildContext context) {<br>    return button(<br>      events: {<br>        &#39;click&#39;: (_) {<br>          setState(() {<br>            count++;<br>          });<br>        },<br>      },<br>      [.text(&#39;Counter is $count&#39;)],<br>    );<br>  }<br>}</pre><p>But wait… Why is Widget2 a StatefulComponent that supports the use of an interactive element- the button, when by default a component is non-interactive?</p><p>This is where the <a href="https://docs.jaspr.site/dev/modes">rendering mode</a> comes into play. When rendering on client-side, a StatefulComponent is pretty much a StatefulWidget . But when rendering mode is static or server , the interactive elements will not affect Widget2 s state.</p><p>This introduces the @<a href="https://docs.jaspr.site/api/utils/at_client">client</a> annotation. There needs to be a single @client annotation being used in the tree/branch. And annotating a component with this will make sure it is set up to receive events from the user.</p><p>So, go ahead and annotate the Widget2 with @client and watch your counter work.</p><pre><br>@client<br>class Widget2 extends StatefulComponent {<br>...</pre><h3>Rendering Modes</h3><p>You already have the official docs to understand this. But, to summarise-</p><ol><li><strong>Client</strong> Mode: The website lives on the user’s device.</li><li><strong>Static</strong> Mode: The website content never changes. All files are generated statically and the Dart server isn’t required for any processes.</li><li><strong>Server</strong> Mode: The website content can change frequently and a live Dart server is required to ensure functionality.</li></ol><h4>Advantages of Server Mode</h4><p>A live Dart server helping your app/site at every step. A browser simply provides an environment to run on, but the server is what makes your website run.</p><p>The live Dart server takes away most of the workload. It ensures that not all the libraries/JS files are downloaded onto the client’s device and ensures a fast and secure interface.</p><p>For example, a social media website would need to have a live server running. There would be a need to have the posts keep coming, comment section loading, likes count, etc. <br>But, a blog site or a portfolio website that changes very infrequently and doesn’t need a server running to process an action, the <strong>static</strong> rendering mode would be your best friend.</p><h3>Server Mode Components</h3><p>So how would you harness the power of having a server? You put the brunt of tasks onto it while giving the platform what to render. This is how everything remains SEO-friendly.</p><h4>AsyncStatelessComponent</h4><p>Study it <a href="https://docs.jaspr.site/api/components/async_components">here</a>.</p><p>This component lets the server do the fetch and then renders the entire component. You might think this isn’t very SEO-friendly but, it is. The server pauses any request’s resolution until the data fetch completes and then serves the entire thing.</p><p>Try this:</p><pre>class SunnyComponent extends AsyncStatelessComponent {<br>  @override<br>  Future&lt;Component&gt; build(BuildContext context) async {<br>    bool isSunny = await _observeWeather();<br>    return .text(isSunny ? &#39;Must be sunny&#39; : &#39;No sun&#39;);<br>  }<br><br>  Future&lt;bool&gt; _observeWeather() async {<br>    await Future.delayed(Duration(seconds: 2));<br>    return Random().nextBool();<br>  }<br>}</pre><h4>PreloadStateMixin</h4><p>Study this one <a href="https://docs.jaspr.site/api/utils/preload_state_mixin">here</a>.</p><p>The same working as AsyncStatelessComponent but this lets us build a StatefulComponent . Let’s rebuild our SunnyComponent and give it a button for fetch.</p><pre><br>@client<br>class SunnyComponent extends StatefulComponent {<br>  @override<br>  State&lt;SunnyComponent&gt; createState() =&gt; _SunnyComponentState();<br>}<br><br>class _SunnyComponentState extends State&lt;SunnyComponent&gt; with PreloadStateMixin {<br>  late bool isSunny;<br>  @override<br>  Future&lt;void&gt; preloadState() async {<br>    isSunny = await _observeWeather();<br>  }<br>  Future&lt;bool&gt; _observerWeather() async {<br>    await Future.delayed(Duration(seconds: 2));<br>    return Random().nextBool();<br>  }<br><br>  @override<br>  Component build(BuildContext context) {<br>    return button(<br>      events: {<br>        &#39;click&#39;: (_) async {<br>          isSunny = await _observeWeather();<br>          setState(() {});<br>        },<br>      },<br>      [.text(isSunny ? &#39;Must be sunny&#39; : &#39;No sun&#39;)],<br>    );<br>  }<br>}</pre><p>Did it work?</p><p>When you run this, it will give you this error: <br><em>Error on building component: LateInitializationError: Field ‘isSunny’ has not been initialized.<br></em>But the code seems fine. Then why?</p><p>This happened because when preloadState() ran on the server, it couldn’t provide its value to the isSunny variable on client. The client can’t run preloadState() so when the client tried to access the value, it found the variable wasn’t initialised altogether.</p><h3>Introducing @sync</h3><p>Add the annonation @sync to the variable isSunny .</p><pre>  @sync<br>  late bool isSunny;</pre><p>Now, when you run your project, or serve it, you would have found a file was generated for your component. If your file was named sunny_component.dart , you would find a file in the same folder with the name sunny_component.sync.dart . Import it and add the generated Mixin SunnyComponentStateSyncMixininside it.</p><p>Your code should now look like this:</p><pre>import &#39;sunny_component.sync.dart&#39;;<br><br>class _SunnyComponentState extends State&lt;SunnyComponent&gt; with <br>      PreloadStateMixin, SunnyComponentStateSyncMixin {<br>  @sync<br>  @override<br>  late bool isSunny;<br><br>  @override<br>  Future&lt;void&gt; preloadState() async {<br>    isSunny = await _observeWeather();<br>  }<br>...</pre><p>What happened here is that now there exists a hand-off route between the server’s instance of isSunny and the client’s isSunny . On preloadState() , the server provides the client with the value and from then on, it stays with the client.</p><p>I’d suggest going through the <a href="https://docs.jaspr.site/api/utils/sync_state_mixin">SyncStateMixin</a> as well. @sync just makes this mixin easier to implement.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1233310333%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1233310333%3Ffl%3Dtl%26fe%3Dec&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2208937387-a577a7fbccbc07230cd1babf6ee999c7a549f020ca3d688dfa35eb84d5fa39e5-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7e56813b36f992a32fbf436b365fa18/href">https://medium.com/media/c7e56813b36f992a32fbf436b365fa18/href</a></iframe><p>Jaspr is a beast of its own kind. With components behaving differently in different modes- it is unforgiving. Take your time with it, and sit down with a good cup of coffee when you start experimenting.</p><p>This was enough for one article. I’ll cover Styling in the next one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*zydovu8dmh-lqkEtPtXh9w@2x.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deb90f13aa34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Web: How I built an Instagram Chat Reader]]></title>
            <link>https://uncoded-decimal.medium.com/flutter-web-how-i-built-an-instagram-chat-reader-b1d8c79de5d9?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1d8c79de5d9</guid>
            <category><![CDATA[web-browser-api]]></category>
            <category><![CDATA[flutter-web]]></category>
            <category><![CDATA[instagram-chat]]></category>
            <category><![CDATA[web-api-tutorial]]></category>
            <category><![CDATA[flutter-web-development]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Tue, 26 May 2026 11:52:20 GMT</pubDate>
            <atom:updated>2026-05-26T11:52:20.019Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve been following my journey through the MDN Web API Docs, you’ll probably want an update on what I had been building with all the knowledge.</p><figure><img alt="medium articles series banner" src="https://cdn-images-1.medium.com/max/1024/1*mLhZRnluVgyQY8bW2BgZww.png" /></figure><h3>Introduction</h3><p>I chose to work on an Instagram Chat Reader because with the recent privacy-ending update from Meta, I wanted to start using the app lesser. I went ahead with exporting my data but oh god — it was unreadable.</p><p>To make all that work easier, I built the app for web: <a href="https://igchatreader.netlify.app/">https://igchatreader.netlify.app/</a>.</p><h3>Tools</h3><p>I’m very experienced with Flutter and since it is a very good UI development framework, I decided to use it for a web app.</p><p>I also wished for my friends to be able to use the tool so going with a Web app made more sense because I could offer it to anyone it would work regardless of their devices.</p><h3>How it works</h3><p>The app makes use of a number of browser apis.</p><p>The file drag ‘n drop and the picker works because the flutter app adds the required HTML elements to the DOM. These are the HTMLInputElement and the onDrop listener on the body element. I wrote about DOM Manipulation in my article <a href="https://medium.com/@uncoded-decimal/translating-mdn-web-apis-docs-to-flutter-dom-manipulation-497ccf3ee7e9">here</a>.</p><p>The unarchiving of the file is done using the dart plugin archive . You can find it <a href="https://pub.dev/packages/archive">here</a>.</p><p>The controllers then go through the listing, finding and indexing all the files and media using OPFS. I wrote about OPFS <a href="https://medium.com/@uncoded-decimal/translating-mdn-web-apis-docs-to-flutter-opfs-cd0de8e1a0b7">here</a>.</p><p>Further in the app you’ll find the feature that reads and restores your progress. This was done using localStorage . I wrote about using Storage APIs <a href="https://medium.com/@uncoded-decimal/translating-mdn-web-apis-docs-to-flutter-storage-api-9bf0e8610a05">here</a>.</p><p>The app also allows you to select specific messages and export them as an image. To accomplish that I used the flutter package screenshot . You can learn about it <a href="https://pub.dev/packages/screenshot">here</a>.</p><h4>Responsive UI</h4><p>With web comes the complication of your one app being able to run on multiple types of screen. And while it isn’t easy to cover every use case, I built a tool that has had my back so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2svTI9mW1BNLvjyT6e07uQ.gif" /><figcaption>A Demo of how responsive the web app is</figcaption></figure><p><strong><em>Gist:</em></strong><em> </em><a href="https://gist.github.com/uncoded-decimal/c8b9ce16c03f757915a792c176397cd8"><em>https://gist.github.com/uncoded-decimal/c8b9ce16c03f757915a792c176397cd8</em></a><em><br></em><strong><em>Medium Article:</em></strong><em> </em><a href="https://medium.com/@uncoded-decimal/multiple-screen-parameters-support-in-flutter-faa7759b48bd"><em>https://medium.com/@uncoded-decimal/multiple-screen-parameters-support-in-flutter-faa7759b48bd</em></a></p><h4>Data Setup</h4><p>After unarchiving of data, it is handled through models and put storage using the browser’s OPFS feature. The structure is so: root/username/filetype/file .</p><p>Once you click on a username, the HTML files are being read and loaded in as the chat progress goes further. For all the media files- images, audios and videos, they’re all loaded in with their connected HTML files into the memory altogether.</p><p>When a chat message with an attachment becomes visible, the media files’ blob url is created. This url is then used to load in the image, open the video in a new tab or as the url provided into the DOM element as the audio source. (<em>You can read about the Audio player element in my intro article </em><a href="https://medium.com/@uncoded-decimal/translating-mdn-web-apis-docs-to-flutter-afacae7f0068"><em>here</em></a><em>.)</em></p><p>Soon as the chat message goes out of the cache length of the ListView, the blob url is revoked.</p><p><em>I would never have realised how important it is to manage the URL lifecycle until this app. Just managing these URLs brought the memory usage of my app down by a third.</em></p><h4>Thumbnail Generation Service</h4><p>I wanted to make the UI better for the attachments. So I queried to find an image generation code block. It lead me to a JS script. This is a case of JS inter-op and I’ll paste the code here:</p><pre>  &lt;script&gt;<br>    async function generateThumbnail(blobUrl) {<br>      return new Promise((resolve, reject) =&gt; {<br>        const video = document.createElement(&#39;video&#39;);<br>        video.src = blobUrl;<br>        video.addEventListener(&#39;loadeddata&#39;, () =&gt; {<br>          video.currentTime = 1;<br>        });<br>        video.addEventListener(&#39;seeked&#39;, () =&gt; {<br>          const canvas = document.createElement(&#39;canvas&#39;);<br>          canvas.width = video.videoWidth;<br>          canvas.height = video.videoHeight;<br>          canvas.getContext(&#39;2d&#39;).drawImage(video, 0, 0);<br>          resolve(canvas.toDataURL(&#39;image/jpeg&#39;));<br>        });<br>        video.addEventListener(&#39;error&#39;, () =&gt; reject(&#39;Failed&#39;));<br>        video.load();<br>      });<br>    }<br>  &lt;/script&gt;</pre><h3>Outcome and Thoughts</h3><p>I enjoyed the journey this project took me on. I do not wish to stop working on the app but I have accomplished everything I set out to do with this project.</p><p>You can find the Code here: <a href="https://github.com/uncoded-decimal/ig_chat_reader">https://github.com/uncoded-decimal/ig_chat_reader</a></p><p>My Medium article series covering all the Web APIs used: <a href="https://uncoded-decimal.medium.com/list/mdn-web-tutorial-for-flutter-web-developers-e469b7c9d50c">https://uncoded-decimal.medium.com/list/mdn-web-tutorial-for-flutter-web-developers-e469b7c9d50c</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*bRRt5My8ZmrNjpEEGLc7Nw.png" /><figcaption>IG Chat Reader Logo</figcaption></figure><blockquote>- No, I won’t be putting any Ads of any sort because it goes directly against the principle of a Privacy-first product.</blockquote><blockquote>- Yes, I drew the background and the logo myself! Let me know if you want something for yourself.</blockquote><p>Everything I’ve learned and accomplished while working on this app just solidified my understanding of how good a platform a browser can be. The APIs are very mature and the platform so very evolved, I believe everyone should learn to work with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*wxjRtMlhj7-g06LQ7PKUKg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1d8c79de5d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Translating MDN Web APIs docs to Flutter: OPFS]]></title>
            <link>https://uncoded-decimal.medium.com/translating-mdn-web-apis-docs-to-flutter-opfs-cd0de8e1a0b7?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd0de8e1a0b7</guid>
            <category><![CDATA[opf]]></category>
            <category><![CDATA[flutter-web]]></category>
            <category><![CDATA[mdn]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Sun, 10 May 2026 11:45:19 GMT</pubDate>
            <atom:updated>2026-05-10T11:45:19.158Z</atom:updated>
            <content:encoded><![CDATA[<p>So, I built a website using the knowledge gathered through all my previous articles. I built an Instagram chat reader app. I went through a lot of iterations of what works and how to best use these Web APIs. You can browse my website and study it here: <a href="https://igchatreader.netlify.app/">https://igchatreader.netlify.app/</a></p><p>Working through the app, I realised how important the Origin Private File System is for my app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLhZRnluVgyQY8bW2BgZww.png" /></figure><h3>Origin private file system</h3><p>The <strong>origin private file system</strong> (OPFS) is a storage endpoint provided as part of the <a href="https://developer.mozilla.org/en-US/docs/Web/API/File_System_API">File System API</a>, which is private to the origin of the page and not visible to the user like the regular file system.</p><p>The OPFS offers low-level, byte-by-byte file access, which is private to the origin of the page and not visible to the user. As a result, it doesn’t require the same series of security checks and permission grants and is therefore faster than File System Access API calls.</p><p>Diving straight into code, we start by getting a reference to the root OPFS directory:</p><pre>import &#39;package:web/web.dart&#39;;<br><br>final opfsBaseDirectory = await (window.navigator.storage.getDirectory().toDart);</pre><h4><strong>Working with Files</strong></h4><p>We start by using the opfsBaseDirectory reference to get a file handle of type FileSystemFileHandle.</p><pre>  // create file handle<br>  final fileAtRootHandler =<br>      await (opfsBaseDirectory.getFileHandle(<br>        &#39;fileAtRoot&#39;,<br>        // omit this if file already exists<br>        FileSystemGetFileOptions(create: true),<br>      )).toDart;</pre><p>To write to this file:</p><pre>  final fileAsWritableStream = await (fileAtRootHandler.createWritable()).toDart;<br>  final contentToWrite = &#39;Content for File At Root&#39;.toJS as JSAny;<br>  await (fileAsWritableStream.write(contentToWrite).toDart);<br>  await fileAsWritableStream.close().toDart;</pre><p>To read this file:</p><pre>  final fileAsReadable = await (fileAtRootHandler.getFile()).toDart;<br>  final String fileContents = (await (fileAsReadable.text()).toDart).toDart;</pre><p>To delete this file:</p><pre>await opfsBaseDirectory.removeEntry(&#39;fileAtRoot&#39;).toDart;</pre><h4>Working with Folders</h4><p>Same as with files, we start by using the opfsBaseDirectory reference to get a directory handle of type FileSystemDirectoryHandle.</p><pre>  // create folder reference<br>  final folderAtRoot =<br>      await (opfsBaseDirectory.getDirectoryHandle(<br>        &#39;folderAtRoot&#39;,<br>        FileSystemGetDirectoryOptions(create: true),<br>      )).toDart;</pre><p>To read or write a file to this folder, create a file reference at this folder using folderAtRoot:</p><pre> final fileAtLevel1Handle =<br>      await (folderAtRoot.getFileHandle(<br>        &#39;fileAtLevel1&#39;,<br>        FileSystemGetFileOptions(create: true),<br>      )).toDart;</pre><p>Then we can use the earlier file operations to work on this file.</p><p>To delete this folder’s content:</p><pre>  await (folderAtRoot.removeEntry(<br>    &#39;fileAtLevel1&#39;,<br>  )).toDart;</pre><p>Similarly, to delete the entire folder altogether:</p><pre>  await (opfsBaseDirectory.removeEntry(<br>    &#39;folderAtRoot&#39;,<br>    FileSystemRemoveOptions(recursive: true),<br>  )).toDart;</pre><p>To list out the contents of this folder, you’ll have to write your own JS Function for inter-op since, as of May 2026, Flutter hasn’t built it’s own implementations of standard methods such as <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries">entries()</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries">values()</a>, and <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/entries">keys()</a>.</p><p>OPFS has become my new venture. I will be updating my app soon enough.</p><p>I think maybe my old package <a href="https://pub.dev/packages/nd_logs">nd_logs</a> is also due for another update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*wxjRtMlhj7-g06LQ7PKUKg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd0de8e1a0b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Translating MDN Web APIs docs to Flutter: Storage API]]></title>
            <link>https://uncoded-decimal.medium.com/translating-mdn-web-apis-docs-to-flutter-storage-api-9bf0e8610a05?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bf0e8610a05</guid>
            <category><![CDATA[flutter-web]]></category>
            <category><![CDATA[js-localstorage]]></category>
            <category><![CDATA[indexeddb]]></category>
            <category><![CDATA[web-storage-api]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 07:07:14 GMT</pubDate>
            <atom:updated>2026-04-14T07:07:14.088Z</atom:updated>
            <content:encoded><![CDATA[<p>This article covers the subject of Client-side data storage and retrieval using the Browser capabilities with Flutter Web.<em> This, by far, feels like the second most important feature to understand after DOM Manipulation.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLhZRnluVgyQY8bW2BgZww.png" /></figure><p>Since the early days of the web, sites have used <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies">cookies</a>. They’re the earliest form of client-side storage commonly used on the web. They haven’t lost their usability, however, with increased needs of modern tech, we have now started using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API">Web Storage API</a> and the <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB API</a>.</p><figure><img alt="Types of Storage available on Web" src="https://cdn-images-1.medium.com/max/651/1*JXwZ_cr4fJzmwO_vBjK0gg.png" /></figure><p>In this article, we will explore these:</p><ul><li>Cookies</li><li>Cache API</li><li>Session Storage</li><li>Local Storage</li><li>IndexedDB</li></ul><h3>Cookies</h3><p>A <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies">cookie</a> is a small piece of data a server sends to a user’s web browser. The browser may store cookies, create new cookies, modify existing ones, and send them back to the same server with later requests. When you store information in cookies, by default all cookie values are visible to, and can be changed by, the end user.</p><p>Flutter can operate on cookies using the following code:</p><pre>  Future&lt;void&gt; createDefaultCookies() async {<br>    final sessionID = DateTime.now().millisecondsSinceEpoch;<br>    document.cookie = &quot;user-name=Andi&quot;;<br>    document.cookie = &quot;session-id=$sessionID&quot;;<br>  }<br><br>  void printAllCookies() {<br>    debugPrint(document.cookie);<br>  }</pre><p>If you are using cookies, you should study the documentation <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies">here</a>.</p><h3>Cache API</h3><p>The Cache API is designed for storing HTTP responses to specific requests, and is very useful for doing things like storing website assets offline so the site can subsequently be used without a network connection.</p><p>A very small operable code block for flutter:</p><pre>  late final Cache cacheStorage;<br>  <br>  Future&lt;void&gt; openCacheStorage() async {<br>     cacheStorage = await window.caches.open(&quot;default-cache&quot;).toDart;<br>  }<br>  void addRequestToCache(RequestInfo requestToCache, Response responseToCache){<br>    cacheStorage.put(requestToCache, responseToCache);<br>  }</pre><p>If you wish to study these further, here’s the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Cache">documentation</a>.</p><p><em>These are used with Workers and I hope to reach the subject soon for a better use case.</em></p><h3>Web Storage (Session Storage and Local Storage)</h3><p>The Session storage and the Local storage are very similar. The only difference is that localStorage is partitioned by origin only, sessionStorage is partitioned by both origin and browser tabs (top-level browsing contexts). The data in sessionStorage is only kept for the duration of the page session.</p><p>Here are some points to remember:</p><ul><li>A page’s different iframe s also share into the same Storage bucket</li><li>If the page was launched by a different window, a copy of the other page’s session storage is created for the new window and it now becomes separate from the other page.</li><li>A page session lasts as long as the tab or the browser is open, and survives over page reloads and restores.</li><li>Closing the tab/window ends the session and clears the data in sessionStorage.</li><li>localStorage does the same thing, but persists even when the browser is closed and reopened.</li><li>Both sessionStorage and the localStorage are allowed only about 5 MiB of data each. Read about it <a href="https://developer.mozilla.org/en-US/docs/Web/API/Storage_API/Storage_quotas_and_eviction_criteria#web_storage">here</a>.</li></ul><p>Check for availability in Flutter:</p><pre><br>  Future&lt;bool&gt; canUseLocalStorage() async {<br>    try {<br>      /// `sessionStorage` is also availed so<br>      // window.sessionStorage.setItem(&quot;testkey&quot;, &quot;test&quot;);<br><br>      window.localStorage.setItem(&quot;testkey&quot;, &quot;test&quot;);<br>      final testValue = window.localStorage.getItem(&quot;testkey&quot;);<br>      return testValue == &quot;test&quot;;<br>    } on DOMException catch (e) {<br>      debugPrint(&quot;DOMException: ${e.message}&quot;);<br>    } on Exception catch (e) {<br>      debugPrint(&quot;Exception: $e&quot;);<br>    }<br>    return false;<br>  }</pre><p>Read about <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage">Session Storage</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">Local Storage</a> on the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API">official documentation</a>.</p><h3>IndexedDB</h3><p>The <a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API">IndexedDB API</a> is a complete database system available in the browser in which you can store complex related data, videos, images, and pretty much anything else in an IndexedDB instance. It allows you to create a database, then create object stores within that database.</p><blockquote>IndexedDB is a transactional database system, like an SQL-based Relational Database Management System (RDBMS). However, unlike SQL-based RDBMSes, which use fixed-column tables, IndexedDB is a JavaScript-based object-oriented database.</blockquote><p>If you are familiar with Relational Databases, you know the following steps:</p><ol><li>Open a database.</li><li>Create an object store(table) in the database.</li><li>Start a transaction and make a request to do some database operation, like adding or retrieving data.</li><li>Wait for the operation to complete by listening to the right kind of event.</li></ol><p><em>The code itself is huge, I’ll attach the </em><a href="https://gist.github.com/uncoded-decimal/1c49fc13acb0829112fdc67554427680"><em>gist</em></a><em> at the end to make it easier.</em></p><p>Here’s how it looks:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F1181910352%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F1181910352&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F2144391829-2003de6745de4480218b00d94ef346aea18721c115fe152f3eded77febb0ffe5-d_1280%3Fregion%3Dus&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1636" frameborder="0" scrolling="no"><a href="https://medium.com/media/9844b16b2286fe225026c4af489e0349/href">https://medium.com/media/9844b16b2286fe225026c4af489e0349/href</a></iframe><h3>Explaining the code:</h3><p>It’s the controller that’s doing all the work so feel free to open just this one file and study that.</p><h4><strong>Open Table</strong></h4><p>The first thing we do is we open the Database through the method openDB() . Most of the DB operations will require us to add event listeners. In this method, we have the onerror , onsuccess and the onupgradeneeded callbacks. The onupgradeneeded is called when we increase the version of our DB, or the first time we open it and need to setup our table. This setup is handled through _setupTable() .</p><p><em>Note that the IndexedDB calls its tables “object stores”. Probably because it can store literally any item unlike most other dbs.</em></p><p>In _setupTable() , we create our table through createObjectStore() and provide it the auto-incrementing key id . Then we add columns through createIndex() .</p><p><em>We create not just columns but also the indexing keys when we </em><em>createIndex . This helps when traversing the table searching for values.</em></p><p>The openDB() ‘s onsuccess callback will be triggered once the tables are setup. This is where we execute our _onDBOpened() . Here we just call the fetchAllEntries() method.</p><h4><strong>Read Table</strong></h4><p>If you have looked at the code, you might be wondering what this code is for:</p><pre>  IDBObjectStore get tableRef =&gt; _database<br>      .transaction(JSArray().add(_notesTableName.toJS), &quot;readwrite&quot;)<br>      .objectStore(_notesTableName);</pre><p>It looks like it probably just helps reduce the boiler-plate. But not just that, after every query we make to the DB, our transaction is closed. For every other transaction we make, we need to open the table again.</p><p>We use this tableRef to get the number of entries in our table via tableRef.count().onsuccess. We also use this to open a <a href="https://developer.mozilla.org/en-US/docs/Web/API/IDBCursor">Cursor</a> to traverse our table and read all the values in it. cursor.value gives us the data item at the current index only. We have to move this cursor to read the next value via cursor.continue_() . This method triggers the onsuccess callback again and the cursor.value changes to the next entry in the DB. We traverse each entry and udpate our list of notes.</p><h4>Add to Table</h4><p>The code to add an entry into the table is in the _addNote() method. To add an entry, we build an IDBRequest through:</p><pre>    final request = tableRef.add(note.toJson().jsify() as JSAny);</pre><p>Here, we call the add() method. But we have a Dart Object that cannot be directly converted to a Javascript Object. And even then the method needs a JSAny value.</p><p>What this one line is doing is converting the Dart object note to a Map of primitive values in toJson() . Then .jsify() builds it into a JS equivalent which can then be cast into a JSAny.</p><p>The good thing about JS is that the add() method will accept this converted Map even if one of the params is missing and it will insert the only value that you want in the DB without throwing errors.</p><p>When the request is completed, the onsuccess callback is triggered and we call our fetchAllEntries again.</p><p>I will leave it here because these parts seemed like the most unintuitive-to-a-flutter-developer. This article is a head-start to anyone looking. The delete and modify entry operations seem rather straight-forward after this.</p><h4>Code:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bfd061266f4780a686a49715070a8e94/href">https://medium.com/media/bfd061266f4780a686a49715070a8e94/href</a></iframe><p>If you are working on Web, you should be aware of the Browser and Web protocols. I hope this article helps you through understanding the multiple Storage methods available to a Web Developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*wxjRtMlhj7-g06LQ7PKUKg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bf0e8610a05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Translating MDN Web APIs docs to Flutter:Video and Audio API]]></title>
            <link>https://uncoded-decimal.medium.com/translating-mdn-web-apis-docs-to-flutter-video-and-audio-api-752aeec577fc?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/752aeec577fc</guid>
            <category><![CDATA[flutter-web]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[webapi-for-flutter]]></category>
            <category><![CDATA[mdn-web-docs]]></category>
            <category><![CDATA[html-element]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 12:56:42 GMT</pubDate>
            <atom:updated>2026-04-08T13:58:57.754Z</atom:updated>
            <content:encoded><![CDATA[<p>The next topic MDN covers is the Video and audio APIs.</p><figure><img alt="MDN + Flutter" src="https://cdn-images-1.medium.com/max/1024/1*mLhZRnluVgyQY8bW2BgZww.png" /></figure><p>You’ll ask, “T<em>hese can be done by Flutter itself.”<br></em>I’ll respond, <em>“It is entirely possible to have an audio/video format supported by HTML that cannot be processed by Flutter natively.”<br></em>You,<em> “You can’t even see the HTML elements, what’s the point?”</em></p><p>That’s why this article will be covered in these parts:</p><ol><li>Making the flutter app disappear to make the video visible</li><li>Knowledge of the &lt;video&gt; HTML element</li><li>Implementing the HTML element for our Flutter app.</li></ol><p>As for &lt;audio&gt; , we’ve already covered it in the <a href="https://uncoded-decimal.medium.com/translating-mdn-web-apis-docs-to-flutter-afacae7f0068">first article</a>.</p><h3>Making the flutter app disappear…</h3><p>This is also an example of DOM Manipulation but, this certainly requires digging a bit deeper.</p><p>If you’ve been watching the HTML code generated for our flutter app (<em>Right click &gt; Inspect &gt; </em><strong><em>Elements</em></strong><em> tab</em>), you can see the &lt;body&gt; has an element called the &lt;flutter-view&gt; . This is the HtmlElement responsible for displaying the Flutter app and we are going to mess with this.</p><p>Unfortunately, &lt;flutter-view&gt; is not an HTML tag recognised outside of Flutter. So, we have t dig through the children/child nodes found inside the &lt;body&gt; . The following code helps:</p><pre>    // get &lt;flutter-view&gt;<br>    final count = document.body!.childNodes.length;<br>    int flutterViewIndex = 0;<br>    for (int i = 0; i &lt; count; i++) {<br>      final item = document.body!.childNodes.item(i);<br>      flutterViewIndex = item.toString() == &quot;flutter-view&quot; ? i : 0;<br>    }<br>    flutterElement =<br>        document.body!.childNodes.item(flutterViewIndex) as HTMLElement;</pre><h4>Why do we need flutterViewIndex ?</h4><p>We don’t have a direct access to the element so we have to go through each childNode individually. <br>With a very simple HTML you may be able to find it at the first or the last place but, if you Hot Reload your app, you’ll find the flutterViewIndex has now increased by one.</p><p>And your &lt;body&gt; may not be as simple. You, probably, need to add a logo to HTML to make sure there’s a visible element to mark your branding before the Flutter app loads up.</p><h4>Now to make it disappear…</h4><p>We have to update the style property of this element and set the opacity to 0. Let me add an animation to do this:</p><pre>// initialise<br>    _opacityAnimationController =<br>        AnimationController(vsync: vsync)<br>          ..duration = Duration(seconds: 1)<br>          ..addListener(() {<br>            final newOpacity = _opacityAnimationController.value;<br>            flutterElement.style.opacity = newOpacity.toString();<br>            isFlutterViewVisible = newOpacity == 1;<br>          });<br><br>// trigger code<br>      isFlutterViewVisible<br>          ? _opacityAnimationController.reverse(from: 1.0)<br>          : null;</pre><p>Let’s set the HTML background colour to black…</p><pre>// makes the animation visible<br>    document.body?.style.backgroundColor = &quot;black&quot;;</pre><p>Here’s the result:</p><figure><img alt="opacity animation working" src="https://cdn-images-1.medium.com/max/800/1*l5tjF8kmty2EbeTafjWtig.gif" /><figcaption>Looks familiar, doesn’t it?</figcaption></figure><h3>The HTML &lt;video&gt; element</h3><p>I’ll summarise what the <a href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Client-side_APIs/Video_and_audio_APIs">MDN documentation</a> says. You can study the &lt;video&gt; element <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/video">here</a>.</p><p>It has an src attribute where we can provide the address of the video we are trying to play. However, the more compatibility rich approach would avoid adding an src and focus on building the &lt;source&gt; child nodes.</p><p>Here’s an example in HTML:</p><pre>&lt;video controls&gt;<br>  &lt;source src=&quot;rabbit320.mp4&quot; type=&quot;video/mp4&quot; /&gt;<br>  &lt;source src=&quot;rabbit320.webm&quot; type=&quot;video/webm&quot; /&gt;<br>  &lt;p&gt;<br>    Your browser doesn&#39;t support HTML video. Here is a<br>    &lt;a href=&quot;rabbit320.mp4&quot;&gt;link to the video&lt;/a&gt; instead.<br>  &lt;/p&gt;<br>&lt;/video&gt;</pre><ol><li>Multiple &lt;source&gt; elements will make the browser go through the different sources provided and play the first one that the browser/host has the codec to support. Read about it <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/source">here</a>.</li><li>The &lt;p&gt; is a paragraph, this will be visible if the browser doesn’t support any of the provided video sources.</li><li>controls attribute, if mentioned, ensures the browser display it’s own video controls. Otherwise, it doesn’t.</li></ol><p>Now, read more to learn more. Here’s the <a href="https://pub.dev/documentation/web/latest/web/HTMLVideoElement-extension-type.html">web plugin documentation</a> on the HTMLVideoElement.</p><h3>Implementation</h3><p>Let’s add the video element:</p><pre>  void _addVideoElement() {<br>    final windowSize = MediaQuery.of(_navigator.context).size;<br>    final src = &quot;assets/video/example_video.mp4&quot;;<br>    _videoElement =<br>        HTMLVideoElement()<br>          ..controls = false<br>          ..muted = false<br>          ..src = src<br>          ..height = windowSize.height.toInt()<br>          ..width = windowSize.width.toInt()<br>          ..appendChild(Text(&quot;Browser not supported&quot;));<br><br>    document.body?.prepend(_videoElement);<br>  }</pre><p>Here, we use src because the Dart documentation on <a href="https://pub.dev/documentation/web/latest/web/HTMLMediaElement/srcObject.html">srcObject</a> says:</p><blockquote><strong>Note:</strong> As of March 2020, only Safari has full support for srcObject, i.e. using MediaSource, MediaStream, Blob, and File objects as values. Other browsers support MediaStream objects; until they catch up, consider falling back to creating a URL with URL.createObjectURL_static and assigning it to <a href="https://pub.dev/documentation/web/latest/web/HTMLMediaElement/src.html">HTMLMediaElement.src</a> (see below for an example). In addition, as of version 108 Chromium supports attaching a dedicated worker MediaSource object by assigning that object&#39;s <a href="https://pub.dev/documentation/web/latest/web/MediaSourceHandle-extension-type.html">MediaSourceHandle</a> instance (transferred from the worker) to srcObject.</blockquote><p><em>And frankly, I couldn’t figure out how to add multiple sources anyway.</em></p><p>We use this static sizing because otherwise the video plays in it’s original resolution and that may be much bigger than the browser window.</p><p>We prepend our video element here because calling append adds the child to the bottom of the &lt;body&gt; , which makes the element render on <em>top</em> of the &lt;flutter-view&gt; .</p><p>Let me add a few event listeners and move the code around a bit:</p><pre><br>  void _addVideoElement() {<br>    final windowSize = MediaQuery.of(_navigator.context).size;<br>    final src = &quot;assets/video/example_video.mp4&quot;;<br>    _videoElement =<br>        HTMLVideoElement()<br>          ..controls = false<br>          ..muted = false<br>          ..src = src<br>          ..height = windowSize.height.toInt()<br>          ..width = windowSize.width.toInt()<br>          ..appendChild(Text(&quot;Browser not supported&quot;));<br><br>    _textElement =<br>        HTMLHeadingElement.h4()<br>          ..style.color = &quot;yellow&quot;<br>          ..style.visibility = &quot;true&quot;<br>          ..style.fontSize = &quot;20dp&quot;;<br>  }<br><br>  void _addEventListener() {<br>    _opacityAnimationController.addListener(() {<br>      final newOpacity = _opacityAnimationController.value;<br>      flutterElement.style.opacity = newOpacity.toString();<br>      isFlutterViewVisible = newOpacity == 1;<br>      if (newOpacity == 0 &amp;&amp; _videoElement.checkVisibility()) {<br>        _videoElement.play();<br>      } else if (newOpacity == 1) {<br>        _videoElement.pause();<br>      }<br>    });<br><br>    _videoElement<br>      ..onTimeUpdate.listen((Event timeEvent) {<br>        final currentTimestampInMilliseconds = timeEvent.timeStamp.toInt();<br>        final currentTimestampInSeconds =<br>            currentTimestampInMilliseconds ~/ 1000;<br>        _textElement.textContent = currentTimestampInSeconds.toString();<br>      })<br>      ..onEnded.listen((Event _) {<br>        if (!isFlutterViewVisible) {<br>          _opacityAnimationController.forward(from: 0);<br>          _textElement.remove();<br>          _videoElement.remove();<br>        }<br>      });<br>  }<br><br>  void onButtonClick() {<br>    isFlutterViewVisible<br>        ? _opacityAnimationController.reverse(from: 1.0)<br>        : null;<br>    document.body<br>      ?..prepend(_videoElement)<br>      ..prepend(_textElement);<br>  }</pre><p>And here’s the result:</p><figure><img alt="Video player working" src="https://cdn-images-1.medium.com/max/800/1*eV7ezcXbMKJkb2OgDPh9yA.gif" /></figure><p>Thanks for reading! <br>Next up- Canvas and Storage APIs</p><blockquote><strong>Update 1:</strong> I was going to cover the Canvas API but it seems the documentation in the web package is not clear enough while also missing some crucial methods. The 2D graphics wouldn’t find themselves much use with Flutter anyway. However, since Flutter struggles with 3D graphics, using WebGL with HTML deserves it’s own separate article. I will cover that <strong>only if</strong> it isn’t too heavy on the Javascript.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*wxjRtMlhj7-g06LQ7PKUKg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=752aeec577fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Translating MDN Web APIs docs to Flutter: DOM Manipulation]]></title>
            <link>https://uncoded-decimal.medium.com/translating-mdn-web-apis-docs-to-flutter-dom-manipulation-497ccf3ee7e9?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/497ccf3ee7e9</guid>
            <category><![CDATA[mdn]]></category>
            <category><![CDATA[webapi-for-flutter]]></category>
            <category><![CDATA[dom-manipulation]]></category>
            <category><![CDATA[flutter-developer]]></category>
            <category><![CDATA[flutter-web]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Sun, 29 Mar 2026 16:42:58 GMT</pubDate>
            <atom:updated>2026-03-29T21:02:06.472Z</atom:updated>
            <content:encoded><![CDATA[<h3>Translating MDN Web APIs docs to Flutter:DOM Manipulation</h3><p>If you’ve already read my <a href="https://uncoded-decimal.medium.com/translating-mdn-web-apis-docs-to-flutter-afacae7f0068">previous article</a>, you must be wondering if instead of adding the HTML yourself, you can do that programmatically. I attempt the rewrite of my Audio Player implementation through DOM Manipulation in this article.</p><p><em>Again, this is all just good-ol’ human effort.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLhZRnluVgyQY8bW2BgZww.png" /></figure><p>We now know that Web APIs have an entry-point. DOM Manipulation API uses document to expose the launched HTML. The example of the <a href="https://pub.dev/packages/web">package web</a> also shows an example that uses the same keyword.</p><figure><img alt="`document` keyword exposes DOM details" src="https://cdn-images-1.medium.com/max/1024/1*m50cAjq8PuI7XLALsei8CQ.png" /></figure><p>From here on I rely on the Dart compiler to just help me wherever possible.</p><p>The document.body exposes a lot of <em>read-only</em> properties. I spent some time on the children property before I realised it was <em>read-only</em>. But then, I found the method I needed- appendChild() .</p><p>I used the similar method of defining the audioMediaElement and the playButtonElement but this time, I cleaned my index.html and added all the required properties through my Dart code.</p><p>Since I already have a lot of my code written and working, I’ll break my init() and separate the functions by concern.</p><pre>  void init() {<br>    _addChildrenToDOM();<br>    _setupAudioService();<br>    _setupEventListeners();<br>  }<br><br>  void _addChildrenToDOM() {<br>    audioMediaElement =<br>        HTMLAudioElement()<br>          ..className = &quot;audio_player&quot;<br>          ..src = &quot;assets/audio/example_audio.mp3&quot;<br>          ..volume = defaultVolumeValue;<br><br>    playButtonElement =<br>        HTMLButtonElement()<br>          ..className = &quot;paused&quot;<br>          ..title = &quot;Play&quot;<br>          ..textContent = &quot;Play&quot;;<br><br>    document.body<br>      ?..appendChild(audioMediaElement)<br>      ..appendChild(playButtonElement);<br>  }</pre><p>You’ve probably already figured out how the methods _setupAudioService() and _setupEventListeners() are defined.</p><p>From here it was easy, I just ran the project again and it worked!</p><h4>I wonder if we need the Play button…</h4><p>After all, the play button is not some element visible to the user and we can manage the player state otherwise anyway.</p><p>To do this, I just removed all the code associated with the playButtonElement and reduced the onButtonClick() to this:</p><pre>  void onButtonClick() {<br>    if (playButtonState.valueOrNull == &quot;paused&quot;) {<br>      audioContext.resume().toDart.then((_) {<br>        playButtonState.sink.add(&quot;playing&quot;);<br>        audioMediaElement.play();<br>      });<br>    } else if (playButtonState.valueOrNull == &quot;playing&quot;) {<br>      audioContext.suspend().toDart.then((_) {<br>        playButtonState.sink.add(&quot;paused&quot;);<br>        audioMediaElement.pause();<br>      });<br>    }<br>  }</pre><p>And guess what? It works!</p><h4>Can I set it up to play automatically?</h4><p>So I setup the init() like so:</p><pre>  void init() {<br>    _addChildrenToDOM();<br>    _setupAudioService();<br>    _setupEventListeners();<br>    onButtonClick();<br>  }</pre><p>And no, it doesn’t work.</p><p>It doesn’t print any errors in the console either but I suppose the security established through the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices#autoplay_policy">Autoplay Policy</a> can be the reason for it.</p><h3>I wanna do more…</h3><p>Let’s update the app title and margin at the same time.</p><p>We know margin is found inside the style attribute of body , and the DOM title (the text visible as the tab name) is the document title .</p><p>I added a button to add margin to the DOM and update the title with the measure of current margin. Here’s the updatedHomeController :</p><pre>...<br>static const marginStep = 10;<br><br>void _updateTitle(String value) {<br>  document.title = &quot;Margin set $value&quot;;<br>}<br><br>void addMargin() {<br>  final currentMargin = double.parse(<br>    document.body?.style.margin.replaceAll(&quot;px&quot;, &quot;&quot;) ?? &quot;0&quot;,<br>  );<br>  final newMargin = currentMargin + marginStep;<br>  _updateTitle(newMargin.toString());<br>  document.body?.style.margin = &quot;${newMargin}px&quot;;<br> }<br>...</pre><p>And here’s the result:</p><figure><img alt="dynamically adding margins to the document working" src="https://cdn-images-1.medium.com/max/800/1*GiqfRFPF2uS2xddMe6C25A.gif" /><figcaption>Dynamic addition to margin</figcaption></figure><p>Looks clunky, but it works!</p><p><em>Here’s an example of how this is useful- this works for some of those web apps running inside webviews that require allowances for device notches to be able to display UI unhindered.</em></p><p><em>Another example- this is also the working principle of my </em><a href="https://pub.dev/packages/payu_in_web"><em>PayU India Web plugin</em></a><em>.</em></p><p>Similarly, there’s a lot of manipulation we can do.</p><p>That’s all for this article. I will cover more in the next few articles so please stay tuned in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*wxjRtMlhj7-g06LQ7PKUKg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=497ccf3ee7e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Translating MDN Web APIs docs to Flutter: Introduction]]></title>
            <link>https://uncoded-decimal.medium.com/translating-mdn-web-apis-docs-to-flutter-afacae7f0068?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/afacae7f0068</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[webapi-for-flutter]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[mdn]]></category>
            <category><![CDATA[flutter-web]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 11:41:20 GMT</pubDate>
            <atom:updated>2026-03-29T16:46:19.641Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been working with Flutter Web for a while now but I realised that I don’t have much idea of how things work on the native end. Since I could not find a good enough introduction to the Web APIs built for someone coming from a Flutter background, I decided to create one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mLhZRnluVgyQY8bW2BgZww.png" /></figure><p><em>To whomever it may concern, I’ve gone about learning everything from scratch. I have not used any AI agents to help me through and have gone through the Mozilla Developer documentation the old-school way.</em></p><p><em>This article assumes a basic understanding of both Flutter and JS, CSS with HTML.</em></p><h4>Introduction to Web APIs</h4><p>I started at the <a href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Client-side_APIs/Introduction">introduction page</a> and I will just be putting my notes on here.</p><figure><img alt="Browser API types" src="https://cdn-images-1.medium.com/max/828/1*6a339c0VR8OQ0fWh83c98A.png" /></figure><p>This is how the browser APIs enable us:</p><ol><li><strong>DOM Manipulation: </strong>allows you to manipulate HTML and CSS — creating, removing and changing HTML, dynamically applying new styles to your page, etc.</li><li><strong>Fetch: </strong>fetch data from the server to update small sections of a webpage.</li><li><strong>Drawing: </strong>allow you to programmatically update the pixel data contained in an HTML <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/canvas">&lt;canvas&gt;</a> element to create 2D and 3D scenes.</li><li><strong>Audio/Video: </strong>Use of<strong> </strong>multimedia such as creating custom UI controls for playing audio and video, displaying text tracks like captions and subtitles along with your videos or grabbing video from your web camera.</li><li><strong>Device: </strong>enable you to interact with device hardware.</li><li><strong>Storage: </strong>enable you to store data on the client-side.</li><li><strong>Third-party Functions: </strong>These are not built into the browser by default, and you generally have to retrieve their code and information from somewhere on the Web. For example, the <a href="https://developers.google.com/maps/documentation/javascript">Google Maps API</a> allows you to do things like display an interactive map to your office on your website.</li></ol><p>The documentation then presents us with an example of how HTML audio elements can be built into our web page.</p><p>You can view the example <a href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Client-side_APIs/Introduction#how_do_apis_work">here</a>.</p><p><em>It was very hard to figure out on my own but I now have a basic understanding. This is a very good example to understand for a beginner.</em></p><p>In your index.html , which is the only HTML page loaded for your Flutter Web apps, update the body so:</p><pre>&lt;body&gt;<br>  &lt;script src=&quot;flutter_bootstrap.js&quot; async&gt;&lt;/script&gt;<br>  &lt;audio&gt;&lt;/audio&gt;<br>  &lt;button class=&quot;paused&quot;&gt;Play&lt;/button&gt;<br>  &lt;br /&gt;<br>  &lt;input type=&quot;range&quot; min=&quot;0&quot; max=&quot;1&quot; step=&quot;0.01&quot; value=&quot;1&quot; class=&quot;volume&quot; /&gt;<br>&lt;/body&gt;</pre><p>Since, we are working with Flutter, I’ve separated the view and the controller. And I have used these packages:</p><pre>  rxdart: ^0.28.0<br>  web: ^1.1.1</pre><p>Here’s the HomeView class- as simple as possible, with a StreamBuilder to ensure the button state updates with playback:</p><pre>class HomeView extends StatelessWidget {<br>  final HomeController _controller;<br>  HomeView({super.key}) : _controller = HomeController()..init();<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      floatingActionButton: StreamBuilder&lt;String&gt;(<br>        stream: _controller.playButtonState.stream,<br>        builder: (context, snapshot) {<br>          return FloatingActionButton(<br>            onPressed: _controller.onButtonClick,<br>            child: Icon(<br>              snapshot.data == &quot;playing&quot; ? Icons.pause : Icons.play_arrow,<br>            ),<br>          );<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>And here’s the HomeController that I will explain in the following sections:</p><pre><br>class HomeController {<br>  late HTMLMediaElement audioMediaElement;<br>  late HTMLButtonElement playButtonElement;<br>  late AudioContext audioContext;<br><br>  final BehaviorSubject&lt;String&gt; playButtonState = BehaviorSubject.seeded(<br>    &quot;paused&quot;,<br>  );<br><br>  void init() {<br>    playButtonElement = document.querySelector(&quot;button&quot;) as HTMLButtonElement;<br><br>    audioMediaElement = document.querySelector(&quot;audio&quot;) as HTMLMediaElement;<br>    audioMediaElement.src = &quot;assets/audio/example_audio.mp3&quot;;<br>    <br>    audioContext = AudioContext();<br>    final source = audioContext.createMediaElementSource(audioMediaElement);<br>    source.connect(audioContext.destination);<br><br>    playButtonElement.addEventListener(<br>      &quot;click&quot;,<br>      (Event _) {<br>        if (playButtonElement.classList.contains(&quot;paused&quot;)) {<br>          audioContext.resume().toDart.then((_) {<br>            playButtonElement.classList<br>              ..remove(&quot;paused&quot;)<br>              ..add(&quot;playing&quot;);<br>            playButtonState.sink.add(&quot;playing&quot;);<br>            audioMediaElement.play();<br>          });<br>        } else if (playButtonElement.classList.contains(&quot;playing&quot;)) {<br>          audioContext.suspend().toDart.then((_) {<br>            playButtonElement.classList<br>              ..add(&quot;paused&quot;)<br>              ..remove(&quot;playing&quot;);<br>            playButtonState.sink.add(&quot;paused&quot;);<br>            audioMediaElement.pause();<br>          });<br>        }<br>      }.toJS,<br>    );<br><br>    // https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement#events<br>    audioMediaElement.addEventListener(<br>      &quot;ended&quot;,<br>      (Event _) {<br>        playButtonElement.classList<br>          ..add(&quot;paused&quot;)<br>          ..remove(&quot;playing&quot;);<br>        playButtonState.sink.add(&quot;paused&quot;);<br>      }.toJS,<br>    );<br>  }<br><br>  Future&lt;void&gt; onButtonClick() async {<br>    playButtonElement.click();<br>  }<br>}</pre><p>So, now that you have your basic code, run it and make sure it works.</p><h4>Explanation line-by-line</h4><p>We make sure the init() is called only once. If this method is called again, it will cause overloading of the elements.</p><pre>playButtonElement = document.querySelector(&quot;button&quot;) as HTMLButtonElement;</pre><p>This line adds a reference to the HTML button that we have added.</p><pre>playButtonElement.click();</pre><p>This line ensures the expected behaviour of our FloatingActionButton which allows for play/pause operations. This triggers the click callback event.</p><pre>audioMediaElement = document.querySelector(&quot;audio&quot;) as HTMLMediaElement;<br>audioMediaElement.src = &quot;assets/audio/example_audio.mp3&quot;;</pre><p>The first line ensures we have a reference to the &lt;audio&gt; element on our HTML page.</p><p>Since, we are working with Flutter, I chose to provide the audio source from an audio file recognised by our Flutter project. I put the file in assets/audio/example_audio.mp3.</p><p>To ensure the file has been provided correctly, navigate to <em>http://</em>&lt;localhost&gt;<em>/assets/audio/example_audio.mp3 </em>in your launched browser window. If the audio file was added successfully, you will see a playback UI.</p><pre>    audioContext = AudioContext();<br>    final source = audioContext.createMediaElementSource(audioMediaElement);<br>    source.connect(audioContext.destination);</pre><p>AudioContext is like an audio playback service we have to connect to to ensure playback services.</p><p>We pair our audioMediaElement with the AudioContext and create a source .</p><p>The source is then provided the destination of our audio service.</p><pre>playButtonElement.addEventListener(<br>      &quot;click&quot;,<br>      (Event _) {<br>        if (playButtonElement.classList.contains(&quot;paused&quot;)) {<br>          audioContext.resume().toDart.then((_) {<br>            playButtonElement.classList<br>              ..remove(&quot;paused&quot;)<br>              ..add(&quot;playing&quot;);<br>            playButtonState.sink.add(&quot;playing&quot;);<br>            audioMediaElement.play();<br>          });<br>        } else if (playButtonElement.classList.contains(&quot;playing&quot;)) {<br>          audioContext.suspend().toDart.then((_) {<br>            playButtonElement.classList<br>              ..add(&quot;paused&quot;)<br>              ..remove(&quot;playing&quot;);<br>            playButtonState.sink.add(&quot;paused&quot;);<br>            audioMediaElement.pause();<br>          });<br>        }<br>      }.toJS,<br>    );</pre><p>The addEventListener is the function of its namesake. This can be of three types:</p><pre>addEventListener(type, listener)<br>addEventListener(type, listener, options)<br>addEventListener(type, listener, useCapture)</pre><p>Every element will have its own definition that we will need to look up. We do not get a defined event listener callback for Dart because JS allows function overloading. And since we are writing our code in Dart, we need to convert it to JS by calling toJS .</p><p>In our listener, we provide a method with async operations. These cannot be translated directly from Dart to JS and so we use the .then() architecture to ensure we wait for the JS async operations to conclude for our Dart operations to proceed.</p><p>We perform play/pause(resume/suspend) operations through methods built for our audio service. We then go on to manipulate the classlist of the button element, update the playback state in our state stream and manipulate the playback through the audioMediaElement operations.</p><p>We then repeat the same thing for our audioMediaElement to ensure UI/function updates when the audio playback is finished( ended).</p><h4>Adding volume controls</h4><p>Instead of reading input from the &lt;input&gt; element added to the index.html , I add a Slider to the UI.</p><p><em>The documentation says to work with a </em><em>GainNode . I tried to set it up but updating the </em><em>value of </em><em>gain didn’t update the output. I also had the </em><em>connect method called as well so, if anyone can figure it out, please let me know.</em></p><p>I found the simple way working- the audioMediaElement has a volume key which can be updated very simply.</p><p>My updated controller looks so:</p><pre><br>  static const defaultVolumeValue = 0.1;<br>  final BehaviorSubject&lt;double&gt; volumeSubject = BehaviorSubject.seeded(<br>    defaultVolumeValue,<br>  );<br><br>  void init(){<br>    ...    <br>    // volume setup<br>    audioMediaElement.volume = defaultVolumeValue;<br>    volumeSubject.stream.listen((newVolume) {<br>      audioMediaElement.volume = newVolume;<br>    });<br>    ...<br>  }<br><br>  void onVolumeUpdate(double value) {<br>    volumeSubject.sink.add(value);<br>  }</pre><p>To summarise,</p><ol><li>Web APIs have an entry-point- AudioContext in our case; document and canvas are more examples.</li><li>Web APIs use events like click , ended , etc to handle changes in state. We can read these through Event Listeners.</li><li>Web APIs have security mechanisms built-in wherever required (<a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices#autoplay_policy">Autoplay Policy</a> for playing audio).</li></ol><p>That’s all for this article. I will cover more in the next few articles so please stay tuned in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*wxjRtMlhj7-g06LQ7PKUKg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afacae7f0068" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responsive screen UI support in Flutter]]></title>
            <link>https://uncoded-decimal.medium.com/multiple-screen-parameters-support-in-flutter-faa7759b48bd?source=rss-5b4f618d314d------2</link>
            <guid isPermaLink="false">https://medium.com/p/faa7759b48bd</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[multiscreen]]></category>
            <category><![CDATA[foldable-phone]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[responsive-web-design]]></category>
            <dc:creator><![CDATA[Andi]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 19:06:17 GMT</pubDate>
            <atom:updated>2026-05-26T12:09:11.204Z</atom:updated>
            <content:encoded><![CDATA[<h3>Multiple screen parameters handling in Flutter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*nNYRUHmh_QCIGdOTRSnc9Q.gif" /><figcaption>A demo representation of this idea</figcaption></figure><blockquote><strong>Update 2:</strong> If you wish to see a live product built using this code, check this out: <a href="https://igchatreader.netlify.app/">https://igchatreader.netlify.app/</a></blockquote><blockquote><strong>Update 1:</strong> I recently learned that not all flutter widgets receive text scale factors from ThemeData . However, MediaQuery is still used to render. MediaQueryData itself has support for the factor through a textScaler . So I’ve created a new widget within the repository called MediaQueryUpdateWrapper which readily updates the UI as the screen changes. This, however, should only be provided once and at the base.</blockquote><p>Android 16+ has stopped locking apps into a portrait layout. This is a good feature but, if your device is limited to only one screen, you may expect some turbulence when your phone rotates.</p><p>This was a fun challenge to me!</p><p>Not that we, as mobile app developers don’t know how to accommodate for such updates, but because I wanted to find a way to make things as convenient as possible- And I think I did.</p><p>I’m writing this article for Flutter so, my solution to this employed ThemeExtension and LayoutBuilder to as much degree as I could. Now my solution did need adding rxdart for reactivity, but your own implementation may suffice with Flutter’s own Stream class.</p><p>The file also introduces enums LayoutMode and ScreenDensity to make reading information convenient to the developer. You may change the LayoutMode factors for each as convenient to your use case.</p><p>The ThemeExtension is called the GraphicScaleFactor . This is just a class to hold different the new values that can be provided through the context on every reload. It exposes the ScreenDensity enum to enable the developer usage of specific image resolutions.</p><p>I truly hope the documentation I have provided within the file would be enough. If not, please let me know and I will update this document of the gist to reflect the required changes.</p><p>I have not yet tested these changes in production but also it won’t be limited to me for long now. I did test these changes locally and in dev environments. I used a dummy web app with images and text and watched it readily update the layout whenever I switched the device layout between desktop, tablet, mobile and foldable layouts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*uLMfCS4J5LkpdPCI7E_Epg.gif" /><figcaption>Demo for Desktop apps</figcaption></figure><p>I have also attached an example implementation to educate people on graphic scaling too. ResponsiveGraphicView is a widget that reads the updated scaleFactor from the widget context and uses it to scale the Image and Vectors without manual input required from the developer at each step.</p><p><em>Please note: You will need to update some of this code to meet your personal requirements.</em></p><p>You can find the gist here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7517a26a777039b53f57eec9ec8ca48c/href">https://medium.com/media/7517a26a777039b53f57eec9ec8ca48c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*OQdTKHVuHKf_bO2WRpJPIw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faa7759b48bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>