<?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 Hashmack on Medium]]></title>
        <description><![CDATA[Stories by Hashmack on Medium]]></description>
        <link>https://medium.com/@hashmack007?source=rss-bd72d4d76a2b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yr288wUcjaLIKzde</url>
            <title>Stories by Hashmack on Medium</title>
            <link>https://medium.com/@hashmack007?source=rss-bd72d4d76a2b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:27:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hashmack007/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[“Purge Everything” Didn’t Purge Everything]]></title>
            <link>https://medium.com/@hashmack007/purge-everything-didnt-purge-everything-261aaae84826?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/261aaae84826</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 18:56:11 GMT</pubDate>
            <atom:updated>2026-11-24T18:56:11.953Z</atom:updated>
            <content:encoded><![CDATA[<h4>Three old settings that almost broke a website migration, and how I fixed each one.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lT-iqa-9NyWoq_uuB-TJ6Q.png" /></figure><p>When you move a website to a new platform, old settings from the previous setup can quietly break the new site.</p><p>I learned this moving a live marketing site off an old CMS and onto a new app running at the edge, behind a CDN. The new code worked on the first deploy. Pages rendered, the blog loaded, the forms worked.</p><p>Then I switched the domain over, and three leftovers from the old setup came out to play. None of them were in the new code. All of them were settings somebody had added years ago and nobody remembered.</p><p>Here they are, in the order they would have hurt.</p><h3>1. Old URLs: every indexed page was one deploy away from a 404</h3><p>The old CMS had its own URL style. /contact-us, /about-us, /blog/page/2, /blog/tag/something. The new site used cleaner paths.</p><p>That’s fine for new visitors. But Google had indexed the old paths, and other sites linked to them. Switch the domain without a plan and every one of those becomes a <strong>404</strong>. Years of search rankings, gone in a deploy.</p><p>The fix is boring and it works. I downloaded the old site’s sitemap.xml, listed every path in it, and decided where each one should go. Pages with a direct match got a one-to-one redirect. Pages with no new home went to the closest useful page, not the homepage by default.</p><p>A few patterns covered dozens of URLs at once, like pagination and tag pages:</p><pre>const MOVED: Record&lt;string, string&gt; = {<br>  &quot;/contact-us&quot;: &quot;/contact&quot;,<br>  &quot;/about-us&quot;: &quot;/&quot;,<br>};<br><br>export function oldUrlRedirect(url: URL): URL | null {<br>  const direct = MOVED[url.pathname.toLowerCase()];<br>  if (direct) return new URL(direct, url);<br><br>  // Old pagination: /blog/page/2 → /blog?page=2<br>  const paged = /^\/blog\/page\/(\d+)$/.exec(url.pathname);<br>  if (paged) {<br>    const next = new URL(&quot;/blog&quot;, url);<br>    next.searchParams.set(&quot;page&quot;, paged[1]);<br>    return next;<br>  }<br><br>  // Old tag pages have no equivalent, so send them to the blog<br>  if (url.pathname.startsWith(&quot;/blog/tag/&quot;)) return new URL(&quot;/blog&quot;, url);<br><br>  return null;<br>}</pre><p>Two details matter. Use a permanent redirect (301 or 308), never a temporary 302, so search engines move the ranking to the new URL. And go through the sitemap line by line. The pages you forgot about are exactly the ones still getting traffic from somewhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gl3MC-YwCuoVzJX10JJYig.png" /></figure><h3>2. An old redirect rule: a loop waiting to happen</h3><p>Every site has to pick one canonical host: example.com or www.example.com. The new app picked the bare domain and redirected www to it.</p><p>What I almost missed: back when the old CMS was set up, someone had added a rule on the CDN that did the exact opposite. It sent example.com to www. It had been sitting there quietly doing its job for years.</p><p>Put both live at the same time and you get an <strong>endless loop</strong>. The CDN sends the visitor to www, the app sends them back, and the browser eventually gives up with &quot;too many redirects&quot;.</p><p>The fix was deleting the old rule. The lesson is to do it before the switch, not after. Open your CDN’s redirect rules, page rules and anything else that rewrites URLs, and ask of each one: does the new app already handle this? If yes, delete it, so there’s only one place that decides where a request goes.</p><h3>3. An old cache: “Purge Everything” didn’t purge everything</h3><p>This is the one that cost me an evening.</p><p>After the switch, the bare domain served the new site perfectly. But www kept returning the old CMS&#39;s robots.txt, and an old llms.txt with it. The response headers said it was a cache hit.</p><p>Easy, I thought. I purged the cache for that hostname. Same file. I purged those exact URLs. Same file. I hit <strong>“Purge Everything”</strong> for the whole zone and waited. Same file.</p><p>The routing was fine. Adding a query string, which skips the cached copy, returned the new robots.txt straight from the new app. Something was holding on to the old copies, and the purge buttons weren&#39;t reaching them.</p><p>I still don’t fully know why. What I do know is how to make it not matter: <strong>a redirect that runs before the cache</strong>.</p><p>Most CDNs let you run redirect rules at the very front of the request, before the cache is checked and before your app runs. I added one:</p><pre>When:  hostname equals www.example.com<br>Then:  301 redirect to https://example.com + original path<br>       keep the query string</pre><p>Now a request for www.example.com/robots.txt is redirected before it ever reaches the stale copy. The visitor, or the crawler, lands on example.com/robots.txt and gets the fresh file from the new app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5cg4HqGu9bZdoOvJJtI5tQ.png" /></figure><p>It also means the app’s own www redirect is now a backup instead of the main mechanism, which is fine. The edge rule covers every path, including static files that app-level middleware often skips.</p><h3>How I checked it actually worked</h3><p>I didn’t trust the dashboard. I checked from the outside:</p><pre># Should be a 301 pointing at the bare domain<br>curl -sI https://www.example.com/robots.txt | grep -iE &quot;^(HTTP|location)&quot;<br><br># Should be the new file, not the old one<br>curl -sL https://www.example.com/robots.txt | head -5</pre><p>Then I ran Google’s live URL test in Search Console on the homepage. It came back “URL is available to Google” on the first try.</p><h3>What I’d do differently next time</h3><p>I’d do the audit before touching DNS:</p><p><strong>Map every indexed URL</strong> from the old sitemap, and test the redirects on a preview build before going live.</p><p><strong>Read every CDN rule</strong> that touches redirects or rewrites, and delete anything the new app now handles.</p><p><strong>Pick the canonical host and enforce it at the edge</strong> from day one, not as a fix after something goes wrong.</p><p><strong>Test static files on every hostname</strong>, not just pages. robots.txt, sitemap.xml, favicon.ico. That&#39;s where stale copies hide.</p><p>The new code was fine the whole time. It was the old settings that almost took it down.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=261aaae84826" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I open-sourced a full video editor for React. It never uploads a single frame.]]></title>
            <link>https://medium.com/@hashmack007/i-open-sourced-a-full-video-editor-for-react-it-never-uploads-a-single-frame-2bead6eefb36?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bead6eefb36</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 04:31:02 GMT</pubDate>
            <atom:updated>2026-11-22T04:31:02.691Z</atom:updated>
            <content:encoded><![CDATA[<h3>VideoUltra v0.1 is on npm: one component, works on phones, and never uploads your users’ media.</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FuE2_Ybbbr3o%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DuE2_Ybbbr3o&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FuE2_Ybbbr3o%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/32f60b240ede83326b11a8246f46b273/href">https://medium.com/media/32f60b240ede83326b11a8246f46b273/href</a></iframe><h3>Why I built it</h3><p>Want video editing in your app? Today that means one of three things.</p><p>A paid SDK. A server that renders every export. Or months of your own work.</p><p>I wanted a fourth option. One component. Runs on an ordinary phone. Never uploads anyone’s footage.</p><p>So I built VideoUltra: an open-source, MIT-licensed video editor for React and Next.js. Version 0.1 is on npm today.</p><h3>Getting started</h3><pre>npm install @video-ultra/react</pre><pre>import { VideoEditor } from &#39;@video-ultra/react&#39;;<br>import &#39;@video-ultra/react/styles.css&#39;;</pre><pre>export default function Page() {<br>  return (<br>    &lt;div style={{ height: &#39;100dvh&#39; }}&gt;<br>      &lt;VideoEditor onSave={(project) =&gt; saveSomewhere(project)} /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>That’s the whole setup. A project is plain JSON, validated and versioned so old files always open. The editor autosaves in the browser for crash recovery, and onSave hands you the project to store wherever you like.</p><h3>What’s in v0.1</h3><p>The editor is built in three layers. The simple tools come first, and the deeper ones only appear when someone goes looking for them.</p><ul><li><strong>Everyday editing:</strong> trim, split, speed, filters, transitions, text, stickers, music and voiceover, with export to MP4 or WebM. Phones and desktops each get a layout made for them.</li><li><strong>Creative tools:</strong> templates, text and element animations, layers and groups, blend modes, green screen, LUTs, blur areas, shape masks and background removal.</li><li><strong>Pro tools:</strong> keyframes with a graph editor, roll, slip and slide trims, markers, scopes, sound effects such as EQ and noise clean-up, editing several clips at once, HEVC and AV1 export, and proxies for heavy 4K files.</li><li><strong>Captions:</strong> speech to text with styles and word-by-word highlight, plus .srt and .vtt import and export.</li></ul><h3>How it stays fast</h3><p>The features weren’t the hard part. Keeping it smooth on a cheap phone was. Five rules made it work:</p><ul><li><strong>The main thread stays free.</strong> Decoding, drawing, audio mixing, thumbnails, waveforms and export all run in workers, using WebCodecs and WebGPU, with WebGL2 when WebGPU isn’t available. Both draw the same picture.</li><li><strong>React never renders per frame.</strong> The playhead, timecode and meters update outside React, and the timeline is drawn on a canvas.</li><li><strong>Memory stays flat.</strong> Media is read in ranges, never loaded whole, and every video frame is closed as soon as it has been drawn.</li><li><strong>Quality drops before smoothness does.</strong> On a slow device the preview resolution goes down before frames get dropped.</li><li><strong>No special server headers.</strong> It doesn’t need SharedArrayBuffer or cross-origin isolation, so it works inside any app.</li></ul><h3>Captions and AI without sending media away</h3><p>Two optional packages add the heavier features. @video-ultra/captions makes English captions on the device, in a worker. Other languages work through a speech-to-text service you host. @video-ultra/ai removes backgrounds on the device, and connects AI editing and text to speech through your own server. In every case the user&#39;s media stays on their device unless your app decides to store it.</p><h3>Make it yours</h3><p>You can hide or reorder tools, add your own panels, buttons and media sources, and theme it with design tokens. Every label can be translated, and the editor works with a keyboard and a screen reader (WCAG 2.2 AA).</p><h3>Browsers</h3><p>It runs in current Chrome, Edge, Safari on iPhone and Mac, and Firefox: anywhere WebCodecs is available. A browser that can’t run it gets a clear message instead of a broken page.</p><h3>Try it</h3><p>Open the editor in your browser: <a href="https://videoultra.ashvattech.com/editor">videoultra.ashvattech.com/editor</a><br>Read the docs: <a href="https://videoultra.ashvattech.com/docs">videoultra.ashvattech.com/docs</a><br>Read the code: <a href="https://github.com/Ultranmus/video-ultra">github.com/Ultranmus/video-ultra</a></p><p>It’s v0.1, so tell me what breaks. I especially want to hear from anyone on an older phone. That’s the device I care most about getting right.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bead6eefb36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You can now edit your Framer site before you take it home]]></title>
            <link>https://medium.com/@hashmack007/you-can-now-edit-your-framer-site-before-you-take-it-home-f981f10c402f?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f981f10c402f</guid>
            <category><![CDATA[framer]]></category>
            <category><![CDATA[no-code]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 14:16:14 GMT</pubDate>
            <atom:updated>2026-11-11T14:16:14.725Z</atom:updated>
            <content:encoded><![CDATA[<p>Nextify started as a way to get a Framer site out as a Next.js project. Now you can change it first: text, images, icons and styles, right in the live page.</p><p>A few weeks ago I launched <strong>Nextify</strong>: paste a Framer URL, preview the copy, download a Next.js project you own. The copy is exact. Every animation, breakpoint and CMS list runs the way it does on Framer.</p><p>The first question people asked was always the same: <em>“Can I change things before I download it?”</em></p><p>Fair question. Fixing a typo by opening a code editor and hunting through generated markup is not a fun Tuesday. So I built an editor for the copy, and it’s live today.</p><p>Here’s the whole thing in a minute:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FxjLeTXE2q58%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DxjLeTXE2q58&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FxjLeTXE2q58%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3bae493a121519a2edf9a10339b3bdb/href">https://medium.com/media/d3bae493a121519a2edf9a10339b3bdb/href</a></iframe><h3>What you can do</h3><p>After an import finishes, click <strong>Open in editor</strong>. You get your site, running live in the middle of the screen, with a layers panel on the left and a properties panel on the right. Click anything on the page to select it.</p><ul><li><strong>Edit text</strong> in the panel or right on the page. If the same text appears in several places, you see that and can change them all together. Word-by-word animated headlines, hover-state texts and CMS texts are editable too.</li><li><strong>Swap images and videos.</strong> Upload a new file and every use of it on the site changes. You can edit its alt text too.</li><li><strong>Replace icons</strong> with any of 2,130 Lucide and Phosphor icons, in any color.</li><li><strong>Restyle any layer</strong> per breakpoint: show or hide it, padding, size, fill, opacity, radius, border and shadow, separately for desktop, tablet and phone.</li><li><strong>Change site styles.</strong> Edit a color or a text style once and every use on the site follows.</li><li><strong>Edit links, page titles and SEO texts.</strong></li><li><strong>Freeze animations</strong> so the thing you want to click stops running away from you.</li><li><strong>Undo, redo, and autosave.</strong> If your browser crashes, your unsaved changes are offered back the next time you open the editor.</li></ul><p>When you’re done, click <strong>Download</strong> and you get the same Next.js project, with your edits baked in.</p><h3>How it works under the hood</h3><p>The interesting part about editing an exact copy is that you can’t really “own” the page. It’s Framer’s HTML, brought to life by Framer’s runtime. Change the wrong thing and the runtime puts it right back, or breaks.</p><h3>A small agent inside the page</h3><p>The preview runs on a separate domain, so the site’s own scripts can never touch the app. A small script of mine rides along inside the preview. It finds the layers, draws the selection boxes, reports what you clicked, and applies your changes. The editor and the page talk to each other with messages, like two people passing notes through a window.</p><h3>Edits are a layer on top, never a rewrite</h3><p>Your import is never modified. Edits live next to it:</p><ul><li><strong>Text</strong> goes into the site’s content file, which both the HTML and Framer’s runtime read, so a change can’t be undone by a re-render.</li><li><strong>Styles</strong> become an override stylesheet that targets Framer’s own layer classes, one set of rules per breakpoint.</li><li><strong>Images</strong> are served in place of the original file, at the original path. The page doesn’t even know.</li></ul><p>That’s also why “Reset” and “Original” buttons are easy: the original is always still there underneath.</p><h3>Which copy of a text is the real one?</h3><p>Some text on a Framer page comes from the content file. Some comes from the CMS. Some is computed by code, like a clock or the current year. They can look identical. To tell them apart, the agent quietly loads the page a second time in a hidden frame, with every content-file text marked, and lines the two pages up. Anything that carries the mark is editable text. Anything that doesn’t is left alone.</p><h3>Two bugs that taught me something</h3><h3>The freeze button that froze nothing</h3><p>I tested the freeze button on a portfolio full of motion: rotating pills, a ticker, scroll effects. With freeze on, 186 of the 193 moving elements kept moving.</p><p>The button paused the browser’s own animations. But Framer moves most things itself, from JavaScript, one frame at a time. Nothing to pause.</p><p>The fix is a small trick. My script loads before Framer’s, so it wraps the browser’s frame scheduler before Framer ever sees it. While frozen, frame callbacks are held instead of run, and videos pause. On resume, everything carries on from where it was. Same site: <strong>0 elements moving</strong>.</p><h3>The page that never sat still</h3><p>Hiding a layer worked on the canvas, but the layers panel didn’t notice until you reloaded. The panel only refreshed after the page had been quiet for a quarter of a second. On an animated site, the page is never quiet. Now it refreshes after a short pause, or once a second at the latest, whichever comes first.</p><p>Both bugs had the same root: assuming a website sits still. Framer sites don’t.</p><h3>What’s not there yet</h3><ul><li><strong>Adding new sections.</strong> There’s a library of animated components you can drop into your Framer page. It’s coming in the next release, once you can also edit and move what you add.</li><li><strong>Adding or removing CMS items.</strong> You can edit CMS texts, but not change the list itself.</li><li><strong>Text that code computes</strong>, like a live clock or “© 2026”, stays as the site’s code makes it.</li><li><strong>Phones.</strong> The editor needs a bigger screen. On a phone you can still preview.</li></ul><h3>Still free, still my wallet</h3><p>Nextify is free. It runs on free tiers and my own money, so everyone gets 5 imports a day. Editing doesn’t use up imports, so take your time with it. Please don’t script it.</p><p>If you have a Framer site you want in your own repo, import it, fix the bits you always wanted to fix, and download it. Then tell me what broke. That’s the most useful thing you can do for me.</p><p>👉 Try it: <a href="https://nextify.ashvattech.com/">nextify.ashvattech.com</a></p><p>📺 Watch the demo: <a href="https://youtu.be/xjLeTXE2q58">youtu.be/xjLeTXE2q58</a></p><p><em>Only for sites you own or have the rights to. Don’t be that person. 😏</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f981f10c402f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I built an AI video editor you brief by voice. It turns one podcast into a week of posts.]]></title>
            <link>https://medium.com/@hashmack007/i-built-an-ai-video-editor-you-brief-by-voice-it-turns-one-podcast-into-a-week-of-posts-5f06a806c529?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f06a806c529</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[podcasting]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[content-creation]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Wed, 04 Nov 2026 14:13:00 GMT</pubDate>
            <atom:updated>2026-11-04T14:13:00.846Z</atom:updated>
            <content:encoded><![CDATA[<h3>How Recut finds the clips worth sharing, writes the captions, and plans your week, with no database and a free API key.</h3><p>You record a great 60-minute episode. Then it sits there.</p><p>Everyone knows the playbook: cut it into short clips, write a caption for each platform, post through the week. Almost nobody does it, because it takes longer than recording the episode did. Scrubbing for the good moments. Rewriting the same idea four ways for Reels, LinkedIn, X and Shorts. Remembering which clip goes out on Tuesday.</p><p>So I built <a href="https://recut.ashvattech.com/">Recut</a>. You upload the episode. It hands back the 5–8 moments worth sharing, a caption for every platform, and a calendar for the week. And you can brief it out loud, the way you’d brief a human editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*kuSOt43J6Ju_Du527lxhhg.gif" /></figure><h3>What Recut does</h3><p>Here’s the flow, start to finish.</p><p><strong>1. It finds the moments.</strong> Your episode is transcribed with word-level timestamps. Then a model reads the whole thing and ranks the clips that stand on their own. Each clip shows its start and end time, a hook line, and <em>why</em> it was picked. No black box.</p><p><strong>2. It previews without cutting.</strong> Clips play straight from your original file between their timestamps. Want a vertical version? A 9:16 view adds animated captions and exports the video right in your browser.</p><p><strong>3. It writes the captions.</strong> Instagram Reels, LinkedIn, X and YouTube Shorts each get their own length and tone. Every caption is editable.</p><p><strong>4. You talk to it.</strong> Press / and say what you want: &quot;Find me something on the Artemis missions for LinkedIn, keep it serious, no emojis.&quot; Real speech is messy, so Recut handles filler words, tangents and self-corrections like &quot;LinkedIn, no wait, X.&quot; Then it shows what it understood: the topic, platform, tone and rules, plus what it corrected and what it ignored.</p><p><strong>5. It remembers your brand.</strong> Say “no emojis” once and it becomes a saved rule. Recut also learns rules from your own caption edits. When a rule changes a caption, you see the before and after.</p><p><strong>6. It plans your week.</strong> Say “post the Gateway clip on Tuesday” and it lands on Tuesday. Each post gets an Add to Google Calendar link with the caption pre-filled, or you can export the whole week as an .ics file.</p><p><strong>7. It learns what works.</strong> Come back and say “it got 40,000 views” or “it flopped.” Recut saves that and uses it to rank clips in future uploads.</p><p>No account needed to try it. The home page has a demo episode, NASA’s <em>Houston We Have a Podcast</em> episode 100, that runs without any API key.</p><h3>How it’s built</h3><p>The stack is deliberately small: Next.js 16 (App Router), React 19, Tailwind CSS 4 and Groq. There is no database.</p><ul><li><strong>Transcription:</strong> Groq whisper-large-v3-turbo, with word-level timestamps</li><li><strong>Clip finding and captions:</strong> openai/gpt-oss-120b on Groq, with Qwen and gpt-oss-20b as fallbacks</li><li><strong>Storage:</strong> the user’s browser (IndexedDB and localStorage)</li><li><strong>Video export:</strong> Canvas and MediaRecorder, in the browser</li><li><strong>Hosting:</strong> Vercel</li></ul><p>A few decisions shaped everything else.</p><p><strong>The browser does the heavy lifting.</strong> Audio is decoded in the browser, downsampled to 16 kHz mono (what Whisper uses internally) and split into roughly 110-second WAV chunks. Each cut lands at the quietest point near the boundary, so no word gets sliced in half. Three chunks upload in parallel, and the timestamps are stitched back together after.</p><p>Why chunk at all? Vercel caps request bodies at 4.5 MB. A two-minute chunk at 16 kHz fits under that. A one-hour episode doesn’t.</p><p><strong>Bring your own key, or don’t.</strong> A visitor can paste their own free Groq key in Settings. It stays in their browser and goes straight to Groq, never to my server. Without one, requests go through API routes that use a server key. Those routes build the prompts themselves, so nobody can use them as a free, open LLM proxy.</p><p><strong>No database means no accounts.</strong> Projects, Brand Memory, the calendar and learnings all live on the user’s device. That kept the build simple and the privacy story easy to explain.</p><h3>What I learned building it</h3><p><strong>Free tiers shape your architecture.</strong> Groq’s free tier allows about 8,000 tokens per minute. So the transcript is read in windows of about 1,700 words, sized so each prompt plus its answer fits. When a model hits a rate limit, Recut reads the retry-after header, parks that model, and moves to the next one in the chain. Users see a slightly slower answer, not an error.</p><p><strong>Models fail in boring ways. Plan for them.</strong> Sometimes Groq rejects a response because the model’s JSON didn’t validate. It’s transient, so Recut retries up to four times before falling back. Smaller fallback models sometimes return a clip’s title instead of its ID, so the app matches that back to the real clip.</p><p><strong>Ask for exact numbers.</strong> Tell a model “return 5–8 clips” and it returns 5. Ranges read as permission to do the minimum. Asking each window for an exact count, then ranking and trimming, worked much better. Clip length also scales with the episode, because a two-minute upload can’t hold five 30-second clips.</p><p><strong>Don’t trust the model with rules you can check yourself.</strong> If your Brand Memory says “no emojis,” a regex strips them after the model writes. Same for hashtags. The model handles tone and style. The code guarantees the rules that are easy to verify. Then the UI shows the before and after, so nothing changes silently.</p><p><strong>Voice input is a UX problem, not a speech problem.</strong> Transcription is the easy part. The hard part is what people actually say: “um, the one about the moon, for LinkedIn, no wait, X.” Showing what was understood, corrected and ignored is what made voice briefs feel trustworthy.</p><h3>Try it</h3><ul><li><strong>Live app:</strong> <a href="https://recut.ashvattech.com/">recut.ashvattech.com</a>. Click <em>Try the demo episode</em> to try it with no key.</li><li><strong>Walkthrough video (under 2 minutes):</strong> <a href="https://recut.ashvattech.com/demo/recut-demo.mp4">watch it here</a></li><li><strong>Source code (MIT):</strong> <a href="https://github.com/Ultranmus/recut">github.com/Ultranmus/recut</a>. Deploy your own on Vercel with one environment variable, GROQ_API_KEY.</li></ul><p>To upload your own episode, grab a free key at <a href="https://console.groq.com/">console.groq.com</a>. The free tier covers everything.</p><p>If you make a podcast or a video series, I’d love to know which part of the repurposing grind you’d hand off first. Tell me in the comments.</p><p><em>Demo audio: Houston We Have a Podcast, courtesy of NASA. Recut is not affiliated with or endorsed by NASA.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f06a806c529" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I built a tool that turns any Framer site into a Next.js project you own]]></title>
            <link>https://medium.com/@hashmack007/i-built-a-tool-that-turns-any-framer-site-into-a-next-js-project-you-own-3c626bee9e16?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c626bee9e16</guid>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[framer]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[free]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 13:33:08 GMT</pubDate>
            <atom:updated>2026-10-30T13:33:08.928Z</atom:updated>
            <content:encoded><![CDATA[<p>Paste a URL, get a zip. Why I built Nextify, how it works under the hood, and what it can’t do yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*NKlAa6R5ehpmAsbiIFgVFQ.gif" /></figure><p>Framer is the best place I know to design a website. You drag things around, add a hover state, publish, and it’s live. It feels like cheating.</p><p>Then one day you want something Framer doesn’t do. A custom backend. Your own analytics. Hosting next to the rest of your product. The site in your Git repo, where your team can review changes like any other code.</p><p>And you realize your beautiful site lives on someone else’s platform, and there’s no “download” button.</p><p>So I built one.</p><h3>Meet Nextify</h3><p><strong>Nextify</strong> takes a published Framer site and gives it back to you as a real Next.js project. You paste the URL, confirm the site is yours, watch it import, preview it page by page, and download a zip.</p><pre>npm install<br>npm run dev</pre><p>That’s your site, running on your machine. Push it to GitHub, deploy it to Vercel or anywhere else Next.js runs, and change whatever you like.</p><p>It’s free, and it’s live at <a href="https://nextify.ashvattech.com/">nextify.ashvattech.com</a>.</p><h3>My first attempt was a disaster</h3><p>My first idea was the “smart” one: look at the published site, measure everything, and rebuild it from scratch as clean React components. Screenshots at three widths, computed styles, a lot of guessing about structure.</p><p>The results looked nothing like the originals. Animations were gone. CMS content was missing. Interactions were broken. Responsive layouts fell apart between breakpoints. Every site had its own special way of being wrong.</p><p>The lesson took a while to land: <em>a Framer site isn’t just HTML and CSS.</em> It’s HTML that Framer’s own runtime brings to life. Rebuild only the HTML and you’ve copied a photo of the site, not the site.</p><h3>The trick: don’t rebuild it, copy it exactly</h3><p>Framer already server-renders every page. That HTML is exactly what visitors get, and Framer’s runtime then wakes it up with animations, interactions and CMS lists.</p><p>So instead of rebuilding anything, Nextify keeps the HTML exactly as it is and brings everything it needs along. The runtime, the images, the fonts, the videos and the CMS data all get downloaded into the project and served from your own host. The result is identical to the original, because it <em>is</em> the original, just living somewhere you control.</p><p>That sounds simple. It wasn’t.</p><h3>Things that broke along the way</h3><h3>Rewriting JavaScript without breaking it</h3><p>Framer’s runtime is dozens of JavaScript modules that import each other and point at Framer’s CDN. Every one of those URLs has to point at your project instead.</p><p>The quick way is a regex. The quick way also happily “fixes” URLs inside comments and regular expressions and breaks the code. Nextify reads each module with a real JavaScript tokenizer and rewrites only actual strings and template literals.</p><h3>The CMS data is binary, with byte offsets</h3><p>This one was my favorite bug. Framer’s CMS data is a binary file that points into itself by byte position. Change the length of a single URL inside it and every offset after it is wrong, so the whole CMS breaks.</p><p>The fix: rewrite every URL to a local path of <em>exactly the same length</em>, padding it with harmless ./ segments that the browser removes when it resolves the URL. Same bytes in, same bytes out, and it points to your own server.</p><h3>Framer asks for slices of files</h3><p>Framer doesn’t download the whole CMS file. It asks for specific byte ranges through a query parameter and expects them joined together. Plain static hosting can’t do that, so every exported project ships a small Next.js route handler that serves those slices.</p><h3>Making it editable at all</h3><p>A copy you can’t touch isn’t much use. Each page’s body becomes JSX sections, and all of the site’s text is lifted into one content file. Fixing a typo or rewriting a headline means editing one file, not hunting through markup.</p><p>To check all of this, I serve exported sites with every Framer domain blocked. The pages load, hydrate, run their animations and show every image, CMS ones included.</p><h3>Running it on free tiers (and my wallet)</h3><p>Nextify is free for users, and I want to keep it that way. Under the hood:</p><ul><li><strong>Vercel</strong> hosts the app.</li><li><strong>Supabase</strong> handles sign-in and the database.</li><li><strong>Cloudflare R2</strong> stores the exported projects, and a <strong>Cloudflare Worker</strong> serves the previews from a separate domain.</li><li><strong>Google Cloud Run</strong> runs the importer that fetches and packages each site.</li><li><strong>Resend</strong> sends the sign-in emails.</li></ul><p>Free tiers are generous, but they aren’t infinite, and anything above them comes out of my own pocket. So everyone gets <strong>5 imports a day</strong>. Please don’t script it. My wallet is already crying in the corner.</p><h3>What it doesn’t do (yet)</h3><ul><li><strong>It’s Framer-sized JavaScript.</strong> Because the copy includes Framer’s runtime, it’s as heavy as the Framer site it came from. It won’t score like a hand-built, Lighthouse-100 Next.js site.</li><li><strong>The runtime is still Framer’s.</strong> It’s subject to Framer’s terms, which is one more reason Nextify is only for sites you own or have the rights to. The import flow asks you to confirm that every time.</li><li><strong>Editing is code, for now.</strong> Text lives in one file, and everything else is yours to change in your editor.</li></ul><h3>What’s next</h3><p>Two things I’m working on:</p><ul><li><strong>A visual editor</strong> for the copy, so you can change text and images before you download.</li><li><strong>A Framer-free conversion:</strong> the same site as plain Next.js, with Framer’s runtime replaced by a small one of my own. It’s in testing on real Framer templates, and it’s much harder than it sounds.</li></ul><p>If you have a Framer site you’ve outgrown, or one you want sitting in your own repo, give it a try. Tell me what breaks. That’s the most useful thing you can do for me.</p><p>👉 <a href="https://nextify.ashvattech.com/">nextify.ashvattech.com</a></p><p><em>Only for sites you own or have the rights to. Don’t be that person. 😏</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c626bee9e16" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add a full photo editor to your Next.js app in five lines]]></title>
            <link>https://medium.com/@hashmack007/add-a-full-photo-editor-to-your-next-js-app-in-five-lines-44650006f5f1?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/44650006f5f1</guid>
            <category><![CDATA[free]]></category>
            <category><![CDATA[image-editor]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Sun, 27 Sep 2026 15:18:01 GMT</pubDate>
            <atom:updated>2026-09-27T15:18:01.263Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A free, fully typed image editor for React: crop, adjust, annotate, redact and export, non-destructively.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4OJxHWt8XDXE6fhm.jpg" /><figcaption>Preview</figcaption></figure><p>Almost every app ends up needing an image editor. A profile photo needs cropping, a screenshot needs an arrow and a blurred email address, a product photo needs brightening before it goes live.</p><p>The options I found didn’t fit what I wanted: a component that’s free to use in any project, typed end to end, easy to make look like my own app, and ready for Next.js without workarounds.</p><p>So I built <strong>image-ultra</strong>: a free, MIT-licensed image editor component for React and Next.js. Version 0.1 is on npm today.</p><p><strong>Try it in your browser:</strong> <a href="https://imageultra.ashvattech.com/">imageultra.ashvattech.com</a></p><h3>Five lines to a full editor</h3><pre>npm install @image-ultra/react</pre><pre>import { ImageEditor } from &#39;@image-ultra/react&#39;;<br>import &#39;@image-ultra/react/styles.css&#39;;<br><br>export default function Page() {<br>  return &lt;div style={{ height: 600 }}&gt;&lt;ImageEditor src=&quot;/photo.jpg&quot; /&gt;&lt;/div&gt;;<br>}</pre><p>That works as-is in a Next.js App Router page. Once you add handlers like onSave, put the editor in your own component that starts with <br>&#39;use client&#39;, because Server Components can&#39;t pass functions to the browser.</p><p>That’s a complete editor, with these tools:</p><ul><li><strong>Adjust</strong> — crop with aspect-ratio presets, rotate, flip, straighten and fix perspective</li><li><strong>Finetune</strong> — brightness, contrast, curves, levels, white balance, and a one-tap “Auto”</li><li><strong>Filter</strong> — ready-made looks, plus looks your users can save themselves</li><li><strong>Annotate</strong> — arrows, shapes, text and images, with layers, grouping and alignment</li><li><strong>Redact</strong> — blur or pixelate faces, names and numbers</li><li><strong>Stickers, frames, fills and watermarks</strong></li><li><strong>Resize and export</strong> as JPEG, PNG or WebP</li></ul><h3>Every edit is JSON, not pixels</h3><p>This is the design choice I care about most. The editor never changes the original photo. Every crop, slider move and arrow is stored as a small, serializable object, the EditState:</p><pre>&lt;ImageEditor<br>  src={photoUrl}<br>  initialState={savedEdits} // reopen exactly where the user left off<br>  onSave={async (result) =&gt; {<br>    await upload(result.blob);                      // the finished image<br>    await saveEdits(JSON.stringify(result.state));  // the edits that made it<br>  }}<br>/&gt;</pre><p>Because the edits are data, you can:</p><ul><li><strong>Reopen an edit later.</strong> The user fixes one thing without starting over.</li><li><strong>Re-render without the editor UI</strong>, for example to regenerate an image at another size. It runs in the browser, since it needs a canvas:</li></ul><pre>import { renderImage } from &#39;@image-ultra/react&#39;;<br><br>const { blob } = await renderImage(&#39;/photo.jpg&#39;, savedEdits, { mimeType: &#39;image/webp&#39; });</pre><ul><li><strong>Store a few kilobytes</strong> of JSON next to the original, instead of a new copy of every version.</li></ul><p>Undo is unlimited, and every tool has its own reset, so people experiment freely.</p><h3>Big photos, on phones too</h3><p>Modern phone cameras take 48-megapixel photos, and a naive canvas editor falls over at that size, especially on iPhones with their strict memory limits.</p><p>image-ultra renders with <strong>WebGL2</strong> and falls back to Canvas2D where WebGL isn’t available. Sliders update the photo in the same frame you drag them. The preview uses a smaller copy of very large photos, and loads full detail when you zoom in. Exports are always full size: photos bigger than the GPU can hold are exported in tiles.</p><p>On an iPhone, editing holds 59 fps with 12 and 24MP photos, and 48MP photos export at full size.</p><h3>Yours to theme</h3><p>The editor looks like part of your app, not a third-party widget. Every colour, radius and size is a CSS variable:</p><pre>.my-editor .iu-root {<br>  --iu-accent: #155e75;<br>  --iu-radius-md: 4px;<br>}</pre><p>Or use the typed shortcut, which your editor autocompletes:</p><pre>&lt;ImageEditor theme=&quot;light&quot; themeOverrides={{ accent: &#39;#155e75&#39;, radius: &#39;12px&#39; }} /&gt;</pre><p>It supports dark, light, or following the OS setting. There’s no CSS-in-JS runtime: it’s one plain stylesheet. The docs site has a <a href="https://imageultra.ashvattech.com/theming">live theme playground</a> where you pick colours and copy the result.</p><h3>Built for everyone</h3><ul><li><strong>Accessible:</strong> it’s fully usable with a keyboard and works with screen readers. It respects reduced motion, and it’s tested with axe against WCAG 2.2 AA.</li><li><strong>Any language:</strong> every piece of text is a typed label you can translate, and right-to-left layouts (Arabic, Hebrew) work.</li><li><strong>Typed end to end:</strong> TypeScript strict, with no any in the public API.</li><li><strong>Next.js ready:</strong> it’s safe for server-side rendering and ships as a Client Component.</li></ul><h3>A bug I shipped in 0.1.0, and what it taught me about CSS layers</h3><p>Before announcing a release, I install it from npm into a brand-new app, exactly as a new user would. For 0.1.0, that check found a bug that all of my own tests had missed.</p><p>In a fresh create-next-app, the editor looked squashed. Buttons had lost their padding and the Done button was cut off.</p><p>The cause is a feature I’d chosen on purpose. All of the editor’s CSS lives in a cascade layer, @layer image-ultra, so that any CSS you write wins without !important. But the cascade treats <strong>unlayered</strong> CSS as stronger than every layer, whatever its specificity. The default globals.css in create-next-app contains this:</p><pre>* {<br>  padding: 0;<br>  margin: 0;<br>}</pre><p>It’s unlayered, so it beat every rule in the editor. Tailwind v3’s reset does the same.</p><p>The fix is one unlayered rule that uses a lesser-known CSS keyword:</p><pre>.iu-root :where(*) {<br>  all: revert-layer;<br>}</pre><p>Inside the editor, revert-layer rolls every property back to what the cascade layers say, as if the page&#39;s unlayered CSS weren&#39;t there. all doesn&#39;t touch custom properties, so theming with the CSS variables still works exactly as before.</p><p>0.1.1 shipped the fix a few hours later. It also added a test that loads the editor, injects the create-next-app and Tailwind resets, and checks that no element in any tool moves or changes.</p><p>The lesson: <strong>my tests all ran in clean apps, and real apps are never clean.</strong> Installing from npm into a fresh app is now a fixed step of every release.</p><h3>What’s next</h3><p>0.1 is usable today. The API may still change before 1.0, and your feedback decides how. On the list:</p><ul><li>a Web Component build, so Vue, Svelte and Angular apps can use the editor</li><li>optional AI tools as a separate package: background removal, smart crop and automatic redaction</li><li>faster WebP export</li></ul><h3>Try it</h3><ul><li><strong>Live demo and docs:</strong> <a href="https://imageultra.ashvattech.com/">imageultra.ashvattech.com</a></li><li><strong>npm:</strong> <a href="https://www.npmjs.com/package/@image-ultra/react">@image-ultra/react</a></li><li><strong>GitHub:</strong> <a href="https://github.com/Ultranmus/image-ultra">Ultranmus/image-ultra</a> — issues, ideas and stars are all welcome</li></ul><p>If you add it to your app, I’d love to see what you build, and if something’s missing, open an issue and tell me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44650006f5f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Infinite Pagination with Real-Time Updates in Flutter using Firestore]]></title>
            <link>https://medium.com/@hashmack007/building-infinite-pagination-with-real-time-updates-in-flutter-using-firestore-fbbcfb1a9e26?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbbcfb1a9e26</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[infinite-scroll]]></category>
            <category><![CDATA[riverpod]]></category>
            <category><![CDATA[realtime]]></category>
            <category><![CDATA[firestore]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Sun, 01 Sep 2024 14:37:12 GMT</pubDate>
            <atom:updated>2024-09-01T14:41:19.807Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I’ll walk you through implementing infinite pagination with real-time updates using Firestore in a Flutter app. The goal is to load data in chunks from Firestore as the user scrolls through a list and to update the list in real-time whenever there’s a change in the Firestore collection.</p><p><strong>Key Libraries Used:</strong></p><ul><li>flutter_riverpod: For state management.</li><li>cloud_firestore: For interacting with Firestore.</li><li>visibility_detector: To detect when the user scrolls near the end of the list.</li></ul><h4>Step-by-Step Implementation</h4><h4>1. Setting Up Firebase</h4><p>First, initialize Firebase in your main.dart file. Ensure you have configured Firebase correctly in your Flutter app by following the official Firebase documentation.</p><pre>import &#39;package:firebase_core/firebase_core.dart&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_riverpod/flutter_riverpod.dart&#39;;<br>import &#39;firebase_options.dart&#39;; // Your generated Firebase options<br><br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await Firebase.initializeApp(<br>    options: DefaultFirebaseOptions.currentPlatform,<br>  );<br>  runApp(<br>    const ProviderScope(<br>      child: MyApp(),<br>    ),<br>  );<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>      home: const InfiniteRealtimePagination(),<br>    );<br>  }<br>}</pre><h4>2. Creating the Data Model</h4><p>Next, define a model class (DataModel) that represents the data structure in Firestore.</p><pre>class DataModel {<br>  final String description;<br>  final String title;<br>  final int numLikes;<br>  final int numShares;<br>  final String documentId;<br><br>  DataModel({<br>    required this.description,<br>    required this.title,<br>    required this.numLikes,<br>    required this.numShares,<br>    required this.documentId,<br>  });<br><br>  factory DataModel.fromJson(Map&lt;String, dynamic&gt; json) {<br>    return DataModel(<br>      description: json[&#39;description_cum&#39;] ?? &quot;&quot;,<br>      title: json[&#39;title_cum&#39;] ?? &quot;&quot;,<br>      numLikes: json[&#39;num_likes&#39;] ?? 0,<br>      numShares: json[&#39;num_shares&#39;] ?? 0,<br>      documentId: json[&#39;document_id&#39;] ?? &#39;&#39;,<br>    );<br>  }<br>}</pre><h4>3. State Management with Riverpod</h4><p>Use flutter_riverpod to manage the state of your application. Define a DataState class to handle the current state of your data.</p><pre>import &#39;package:cloud_firestore/cloud_firestore.dart&#39;;<br>import &#39;../models/data_model.dart&#39;;<br><br>class DataState {<br>  final List&lt;DataModel&gt; dataModels;<br>  final bool loading;<br>  final bool noMoreData;<br>  final DocumentSnapshot? lastDocument;<br><br>  DataState({<br>    required this.dataModels,<br>    required this.loading,<br>    required this.noMoreData,<br>    required this.lastDocument,<br>  });<br><br>  DataState copyWith({<br>    List&lt;DataModel&gt;? dataModels,<br>    bool? loading,<br>    bool? noMoreData,<br>    DocumentSnapshot? lastDocument,<br>  }) {<br>    return DataState(<br>      dataModels: dataModels ?? this.dataModels,<br>      loading: loading ?? this.loading,<br>      noMoreData: noMoreData ?? this.noMoreData,<br>      lastDocument: lastDocument ?? this.lastDocument,<br>    );<br>  }<br>}</pre><p>Create a DataStateNotifier to handle data fetching logic:</p><pre>import &#39;dart:async&#39;;<br>import &#39;package:cloud_firestore/cloud_firestore.dart&#39;;<br>import &#39;package:flutter_riverpod/flutter_riverpod.dart&#39;;<br>import &#39;../models/data_model.dart&#39;;<br>import &#39;../states/data_state.dart&#39;;<br><br>final dataProviders =<br>    AutoDisposeStateNotifierProvider&lt;DataStateNotifier, DataState&gt;(<br>  (ref) {<br>    final notifier = DataStateNotifier(<br>      ref: ref,<br>      fireStore: FirebaseFirestore.instance,<br>    );<br><br>// This part is particularly useful when you want to temporarily retain the state of a provider to prevent it from being automatically disposed of when there are no active listeners.<br>// You can ignore this if you don&#39;t need to persist data temporarily on widget dispose.<br>    ref.onCancel(() {<br>      final link = ref.keepAlive();<br>      final timer = Timer(const Duration(seconds: 15), () {<br>        link.close();<br>      });<br>      ref.onDispose(timer.cancel);<br>    });<br>    return notifier;<br>  },<br>);<br><br>class DataStateNotifier extends StateNotifier&lt;DataState&gt; {<br>  final FirebaseFirestore fireStore;<br>  final AutoDisposeStateNotifierProviderRef&lt;DataStateNotifier, DataState&gt; ref;<br>  final List&lt;List&lt;DataModel&gt;&gt; allPagedResults = [];<br>  final List&lt;StreamSubscription&lt;QuerySnapshot&lt;Map&lt;String, dynamic&gt;&gt;&gt;&gt; _subscriptions = [];<br>  int pageLimit = 6;<br><br>  DataStateNotifier({<br>    required this.ref,<br>    required this.fireStore,<br>  }) : super(DataState(<br>          dataModels: [],<br>          loading: false,<br>          noMoreData: false,<br>          lastDocument: null,<br>        )) {<br>// Initial data load.<br>    loadMore();<br><br>// You can also set a listener here to for any changes and call the restart() function with new values to switch collection.<br>// listener() {<br>//      restart();<br>// });<br>  }<br><br>  Future&lt;void&gt; loadMore() async {<br>    if (state.loading || state.noMoreData) return;<br><br>    await Future.delayed(Duration.zero);<br>    state = state.copyWith(loading: true);<br><br>    await fetchVideos();<br>  }<br><br>  Future&lt;void&gt; fetchVideos() async {<br>    try {<br>      String languageCode = &#39;en&#39;;<br>      String country = &#39;in&#39;;<br>      String collection = &#39;videos_${country}_$languageCode&#39;; // Here country and langauge can be dynamic and can change depending on other providers.<br><br>      Query&lt;Map&lt;String, dynamic&gt;&gt; query = fireStore<br>          .collection(collection)<br>          .limit(pageLimit)<br>          .orderBy(&#39;created_on&#39;, descending: true);<br><br>      if (state.lastDocument != null) {<br>        query = query.startAfterDocument(state.lastDocument!);<br>      }<br><br>      // current page index<br>      var currentRequestIndex = allPagedResults.length;<br><br>      var snapshots = query.snapshots();<br><br>      final subscription = snapshots.listen(<br>        (QuerySnapshot&lt;Map&lt;String, dynamic&gt;&gt; querySnapshot) {<br>          processData(<br>              querySnapshot: querySnapshot,<br>              currentRequestIndex: currentRequestIndex);<br>        },<br>      );<br>      _subscriptions.add(subscription);<br>    } catch (e) {<br>      log(&#39;error from data_service: $e&#39;);<br>    }<br>  }<br><br>void processData({<br>    required QuerySnapshot&lt;Map&lt;String, dynamic&gt;&gt; querySnapshot,<br>    required int currentRequestIndex,<br>  }) {<br>    if (querySnapshot.docs.isNotEmpty) {<br>      DocumentSnapshot? lastDocument;<br>      final List&lt;DataModel&gt; videos = querySnapshot.docs.map((doc) {<br>        final video = doc.data();<br>        video[&#39;document_id&#39;] = doc.id;<br>        return DataModel.fromJson(video);<br>      }).toList();<br><br>      // Check if the page exists or not<br>      var pageExists = currentRequestIndex &lt; allPagedResults.length;<br><br>      // If the page exists update the articles for that page<br>      if (pageExists) {<br>        allPagedResults[currentRequestIndex] = videos;<br>      }<br>      // If the page doesn&#39;t exist add the page data<br>      else {<br>        allPagedResults.add(videos);<br>      }<br><br>      // Concatenate the full list to be shown<br>      var allVideos = allPagedResults.fold&lt;List&lt;DataModel&gt;&gt;(<br>          [], (initialValue, pageItems) =&gt; initialValue..addAll(pageItems));<br><br>      if (currentRequestIndex == allPagedResults.length - 1) {<br>        lastDocument = querySnapshot.docs.last;<br>      }<br><br>      state = state.copyWith(<br>          dataModels: allVideos,<br>          lastDocument: lastDocument,<br>          noMoreData: videos.length != pageLimit,<br>          loading: false);<br>    } else {<br>      state = state.copyWith(noMoreData: false, loading: false);<br>    }<br>  }<br><br>// Always call this function to clear previous subscriptions before subscribing to a new collection.<br>  Future&lt;void&gt; clearPreviousSubscription() async {<br>    allPagedResults.clear();<br><br>    List&lt;Future&lt;void&gt;&gt; cancelFutures = [];<br><br>    for (var subscription in _subscriptions) {<br>      cancelFutures.add(subscription.cancel());<br>    }<br><br>    // Wait for all cancel futures to complete<br>    await Future.wait(cancelFutures);<br><br>    _subscriptions.clear();<br>  }<br><br>  Future&lt;void&gt; clearData() async {<br>    allPagedResults.clear();<br>    state = state.copyWith(<br>      loading: false,<br>      firstLoad: true,<br>      dataModels: [],<br>      lastDocument: null,<br>      noMoreData: false,<br>    );<br>    await clearPreviousSubscription();<br>  }<br><br>  void restart() async {<br>    await clearData();<br>    loadMore();<br>  }<br><br>  @override<br>  void dispose() async {<br>    await clearPreviousSubscription();<br>    super.dispose();<br>  }<br>}</pre><h4>4. Building the UI</h4><p>Create a UI to display data with infinite scrolling. The InfiniteRealtimePagination widget uses CustomScrollView with SliverList for infinite scrolling.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_riverpod/flutter_riverpod.dart&#39;;<br>import &#39;package:visibility_detector/visibility_detector.dart&#39;;<br>import &#39;../models/data_model.dart&#39;;<br>import &#39;../states/data_state.dart&#39;;<br><br>class InfiniteRealtimePagination extends ConsumerWidget {<br>  const InfiniteRealtimePagination({super.key});<br><br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    final dataState = ref.watch(dataProviders);<br><br>    return dataListBuilder(<br>      loadMore: ref.read(dataProviders.notifier).loadMore,<br>      dataState: dataState,<br>      loader: const Center(<br>        child: CircularProgressIndicator(),<br>      ),<br>      errorWidget: const Center(<br>        child: Icon(Icons.error_outline),<br>      ),<br>      builder: (ctx, index, dataModel) {<br>        return DataCard(<br>          dataModel: dataModel,<br>        );<br>      },<br>    );<br>  }<br>}<br><br>typedef DataBuilder = Widget Function(<br>    BuildContext context, int index, DataModel dataModel);<br><br>Widget dataListBuilder({<br>  required DataState dataState,<br>  required DataBuilder builder,<br>  required Future&lt;void&gt; Function() loadMore,<br>  required Widget loader,<br>  required Widget errorWidget,<br>}) {<br>  if (dataState.noMoreData &amp;&amp; dataState.dataModels.isEmpty) {<br>    return errorWidget;<br>  }<br><br>  final dataModels = dataState.dataModels;<br><br>  return CustomScrollView(<br>    slivers: [<br>      SliverList.builder(<br>        itemBuilder: (ctx, index) {<br>          final dataModel = dataModels[index];<br>          return builder(ctx, index, dataModel);<br>        },<br>        itemCount: dataModels.length,<br>      ),<br>      if (dataState.loading || (!dataState.noMoreData &amp;&amp; dataModels.isNotEmpty))<br>        SliverPadding(<br>          padding: const EdgeInsets.all(8.0),<br>          sliver: SliverFillRemaining(<br>            hasScrollBody: false,<br>            child: VisibilityDetector(<br>              key: const Key(&#39;_loader&#39;),<br>              onVisibilityChanged: (VisibilityInfo info) {<br>                if (info.visibleFraction &gt; 0) {<br>                  loadMore();<br>                }<br>              },<br>              child: loader,<br>            ),<br>          ),<br>        ),<br>    ],<br>  );<br>}<br><br>class DataCard extends StatelessWidget {<br>  final DataModel dataModel;<br>  const DataCard({super.key, required this.dataModel});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Padding(<br>      padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),<br>      child: Container(<br>        decoration: BoxDecoration(<br>          color: Colors.blue.shade100,<br>          borderRadius: BorderRadius.circular(8.0),<br>        ),<br>        padding: const EdgeInsets.all(8.0),<br>        child: Column(<br>          crossAxisAlignment: CrossAxisAlignment.start,<br>          children: [<br>            Text(<br>              dataModel.title,<br>              style: const TextStyle(<br>                fontWeight: FontWeight.bold,<br>                fontSize: 17,<br>              ),<br>            ),<br>            Text(dataModel.description),<br>            const SizedBox(height: 8),<br>            Text(&quot;Likes: ${dataModel.numLikes}&quot;),<br>            Text(&quot;Shares: ${dataModel.numShares}&quot;),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h3>Conclusion</h3><p>With this setup, you now have an app that can efficiently handle infinite scrolling with real-time updates using Firestore and Flutter. The Riverpod state management allows for clean and maintainable code while providing excellent performance. By using CustomScrollView and SliverList, your app will perform smoothly even with a large amount of data.</p><p>If you have any questions or need further clarifications, feel free to ask in the comments!</p><p>Happy Coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbbcfb1a9e26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Dynamic Card Carousels with Polaroid Carousel in Flutter]]></title>
            <link>https://medium.com/@hashmack007/creating-dynamic-card-carousels-with-polaroid-carousel-in-flutter-702545b933dd?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/702545b933dd</guid>
            <category><![CDATA[carousel]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[animation]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[polaroid]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 17:25:15 GMT</pubDate>
            <atom:updated>2023-10-13T17:58:00.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*JRkqRI-f5tLhFVJhqZpaoQ.gif" /></figure><h4>Introduction:</h4><p>Flutter, the open-source UI software development toolkit by Google, empowers developers to build beautiful and interactive user interfaces. If you’re looking to add a unique touch to your app, consider using the “<a href="https://pub.dev/packages/polaroid_carousel">polaroid_carousel”</a> package, which enables you to create dynamic rotating card carousels effortlessly.</p><h4>Getting Started:</h4><p>To begin, add the “<a href="https://pub.dev/packages/polaroid_carousel">polaroid_carousel</a>” package to your Flutter project by including it in your pubspec.yaml file. Installation is straightforward and can be done with a single command.</p><pre>#Installation<br><br>#To use this package, follow these steps:<br><br>#1. Add the latest version of the package to your `pubspec.yaml` file and run `dart pub get`:<br><br>   dependencies:<br>     polaroid_carousel: ^1.0.0<br><br>#2. Import the package in your Dart code and use it in your Flutter app:<br><br>   import &#39;package:polaroid_carousel/polaroid_carousel.dart&#39;;</pre><h4>Usage:</h4><p>Polaroid Carousel allows you to craft captivating carousels with ease. Define your list of widget items and set the translation factor. For items with rotation, wrap each child with a Transform widget and specify the rotateZ angle to your liking.</p><h4>Customization:</h4><p>You have full control over the carousel’s animation order(frontToBack or backToFront), translation(left or right or top or bottom), and rotation(x,y,z). Tailor it to your app’s unique requirements, whether you want a front-to-back or back-to-front animation order.</p><h4>Example:</h4><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;dart:math&#39; show pi;<br>import &#39;package:polaroid_carousel/polaroid_carousel.dart&#39;;<br><br>void main() {<br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  // This widget is the root of your application.<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Flutter Demo&#39;,<br>      theme: ThemeData(<br>        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),<br>        useMaterial3: true,<br>      ),<br>      home: const Example(),<br>    );<br>  }<br>}<br><br>class Example extends StatelessWidget {<br>  const Example({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    List&lt;Widget&gt; list = [<br>      Container(<br>        transformAlignment: Alignment.center,<br>        transform: Matrix4.identity()..rotateZ(pi / 8),<br>        height: 200,<br>        width: 300,<br>        color: Colors.black,<br>      ),<br>      Container(<br>        transformAlignment: Alignment.center,<br>        transform: Matrix4.identity()..rotateZ(pi / 40),<br>        height: 200,<br>        width: 300,<br>        color: Colors.blue,<br>      ),<br>      Container(<br>        transformAlignment: Alignment.center,<br>        transform: Matrix4.identity()..rotateZ(pi / 15),<br>        height: 200,<br>        width: 300,<br>        color: Colors.brown,<br>      ),<br>      Container(<br>        transformAlignment: Alignment.center,<br>        transform: Matrix4.identity()..rotateZ(-pi / 15),<br>        height: 200,<br>        width: 300,<br>        color: Colors.red,<br>      ),<br>      Container(<br>        transformAlignment: Alignment.center,<br>        transform: Matrix4.identity()..rotateZ(-pi / 8),<br>        height: 200,<br>        width: 300,<br>        color: Colors.grey,<br>      ),<br>      Container(<br>        transformAlignment: Alignment.center,<br>        transform: Matrix4.identity()..rotateZ(-pi / 40),<br>        height: 200,<br>        width: 300,<br>        color: Colors.yellow,<br>      ),<br>    ];<br><br>    return Scaffold(<br>      body: Center(<br>          child: PolaroidCarousel(<br>        //these to property are necessary<br><br>        // value to which list item translate<br>        // advice : if the children are rotated like the example and you are not able to specify the translateFactor<br>        // then the max translateFactor should be √((childHeight^2, childWidth^2)) of child with maximum size<br>        //but try to adjust translateFactor according to your need<br>        translateFactor: 360,<br><br>        children: list,<br><br>        // these properties are optional<br><br>        // duration: const Duration(seconds: 1),<br>        // rotate: const Rotate(x: 0.001,y: 0.02,z: 0.001),<br>        // curve: Curves.easeInOut,<br>        // order: Order.frontToBack,<br>        // translate: Translate.top,<br>      )),<br>    );<br>  }<br>}</pre><h4>Conclusion:</h4><p>The “Polaroid Carousel” package opens the door to creative and engaging user interfaces. With its flexibility and customization options, it’s an excellent choice for projects that demand a unique touch.</p><p>Give your app a dynamic edge with Polaroid Carousel, and captivate your users with rotating card carousels!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=702545b933dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Infinite Scroll Pagination in Flutter with StreamBuilder and Loading Indicators]]></title>
            <link>https://medium.com/@hashmack007/infinite-scroll-pagination-in-flutter-with-streambuilder-and-loading-indicators-7bc145c96958?source=rss-bd72d4d76a2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bc145c96958</guid>
            <category><![CDATA[streambuilder]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[infinite-scroll]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Hashmack]]></dc:creator>
            <pubDate>Mon, 09 Oct 2023 17:05:34 GMT</pubDate>
            <atom:updated>2023-10-09T17:15:38.302Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll dive into the world of Flutter, exploring how to implement enhanced infinite scroll pagination using the StreamBuilder widget, and adding a loading indicator to make the user experience even better.</p><h3><strong>Introduction</strong></h3><p>Infinite scroll pagination is a common design pattern that allows users to scroll through an app’s content continuously, loading more data as they reach the end of the currently visible content. Flutter, Google’s UI toolkit for building natively compiled applications, provides several powerful widgets to streamline this process.</p><p>One such widget is StreamBuilder, which facilitates real-time data updates and UI rendering. We’ll leverage StreamBuilder to fetch and display paginated data seamlessly while enhancing the user experience with loading indicators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*NJvv29Tq5EwIWv6dhoc5lA.png" /><figcaption><strong>infinite scrolling with pagination</strong></figcaption></figure><h3>Getting Started</h3><p>Before we dive into the code, ensure you have Flutter installed. If you haven’t already, set up a new Flutter project or use an existing one.</p><h3><strong>The Challenge: Pagination with StreamBuilder</strong></h3><p>Imagine you have a RESTful API serving a list of items, and you want to display these items in your Flutter app while supporting infinite scroll pagination. The challenge is to fetch additional data when the user reaches the end of the current list and continue to do so as long as there’s more data available.</p><h3>Solution: Enhanced Infinite Scroll Pagination</h3><p>Here’s how we can tackle this challenge and enhance it with loading indicators:</p><ol><li>Create a StreamController: We’ll use a StreamController to manage the stream of data we’ll display.</li><li>Implement the Fetch Function: Define a function that fetches data from your API. This function should handle pagination by accepting parameters like page number and page size.</li><li>Add Data to the Stream: As you fetch data, add it to the stream. Be careful not to overwrite previous data; instead, append the new data to the existing list.</li><li>StreamBuilder: Use the StreamBuilder widget to listen to the data stream. When new data is added to the stream, StreamBuilder rebuilds the UI with the updated content.</li><li>Scroll Controller: Add a ScrollController to your scrollable widget (e.g., ListView or GridView). Listen to scroll events, and when the user reaches the end, trigger the fetch function to load more data.</li><li>Loading Indicator: While new data is being fetched and loaded, display a loading indicator, such as a circular progress indicator, below the current content.</li></ol><h3>Code Example</h3><p>Here’s a simplified example that illustrates the method:</p><h4><strong>main.dart</strong></h4><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:fluttertest/fetch_data.dart&#39;;<br>import &#39;package:fluttertest/infinite_scroll_pagination.dart&#39;;<br><br>void main() {<br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  // This widget is the root of your application.<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      title: &#39;Flutter Demo&#39;,<br>      theme: ThemeData(<br>        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),<br>        useMaterial3: true,<br>      ),<br>      home: const InfiniteScroll(),<br>    );<br>  }<br>}<br><br>class InfiniteScroll extends StatelessWidget {<br>  const InfiniteScroll({Key? key}) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    final ScrollController scrollController = ScrollController();<br>    return Scaffold(<br>      backgroundColor: Colors.black,<br>      body: SafeArea(<br>        child: Column(<br>          children: [<br>            Expanded(<br>              child: InfiniteScrollPagination(<br>                scrollController: scrollController,<br>                fetchDataFunction: fetchData,<br>              ),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><h4>infinite_scroll_pagination.dart</h4><pre>import &#39;dart:async&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:fluttertest/item.dart&#39;;<br><br>typedef FetchDataFunction = Future&lt;List&lt;dynamic&gt;&gt; Function(<br>    int currentPage, int pageSize);<br><br>class InfiniteScrollPagination extends StatefulWidget {<br>  final ScrollController scrollController;<br>  final FetchDataFunction fetchDataFunction;<br>  const InfiniteScrollPagination(<br>      {Key? key,<br>      required this.scrollController,<br>      required this.fetchDataFunction})<br>      : super(key: key);<br><br>  @override<br>  State&lt;InfiniteScrollPagination&gt; createState() =&gt;<br>      _InfiniteScrollPaginationState();<br>}<br><br>class _InfiniteScrollPaginationState extends State&lt;InfiniteScrollPagination&gt; {<br>  final StreamController&lt;List&lt;dynamic&gt;&gt; _dataStreamController =<br>      StreamController&lt;List&lt;dynamic&gt;&gt;();<br>  Stream&lt;List&lt;dynamic&gt;&gt; get dataStream =&gt; _dataStreamController.stream;<br>  final List&lt;dynamic&gt; _currentItems = [];<br>  int _currentPage = 1;<br>  final int _pageSize = 60;<br>  late final ScrollController _scrollController;<br>  bool _isFetchingData = false;<br><br>  Future&lt;void&gt; _fetchPaginatedData() async {<br>    if (_isFetchingData) {<br>      // Avoid fetching new data while already fetching<br>      return;<br>    }<br>    try {<br>      _isFetchingData = true;<br>      setState(() {});<br><br>      final startTime = DateTime.now();<br><br>      final items = await widget.fetchDataFunction(<br>        _currentPage,<br>        _pageSize,<br>      );<br><br>      _currentItems.addAll(items);<br><br>      // Add the updated list to the stream without overwriting the previous data<br>      final endTime = DateTime.now();<br>      final timeDifference =<br>          endTime.millisecondsSinceEpoch - startTime.millisecondsSinceEpoch;<br><br>      if (timeDifference &lt; 2000) {<br>        // Delay for 2 seconds if the time taken by the API request is less then 2 seconds<br>        await Future.delayed(const Duration(milliseconds: 2000));<br>      }<br><br>      _dataStreamController.add(_currentItems);<br>      _currentPage++;<br>    } catch (e) {<br>      _dataStreamController.addError(e);<br>    } finally {<br>      // Set to false when data fetching is complete<br>      _isFetchingData = false;<br>      setState(() {});<br>    }<br>  }<br><br>  @override<br>  void initState() {<br>    // TODO: implement initState<br>    super.initState();<br>    _scrollController = widget.scrollController;<br>    _fetchPaginatedData();<br>    _scrollController.addListener(() {<br>      _scrollController.addListener(() {<br>        final maxScroll = _scrollController.position.maxScrollExtent;<br>        final currentScroll = _scrollController.position.pixels;<br><br>        if (currentScroll == maxScroll) {<br>          // When the last item is fully visible, load the next page.<br>          _fetchPaginatedData();<br>        }<br>      });<br>    });<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return StreamBuilder&lt;List&lt;dynamic&gt;&gt;(<br>      stream: dataStream,<br>      builder: (context, snapshot) {<br>        if (snapshot.connectionState == ConnectionState.waiting) {<br>          // Display a loading indicator<br>          return const Center(child: CircularProgressIndicator());<br>        } else if (snapshot.hasError) {<br>          // Handle errors<br>          return Center(child: Text(&#39;Error: ${snapshot.error}&#39;));<br>        } else if (!snapshot.hasData || snapshot.data!.isEmpty) {<br>          // Display a message when there is no data<br>          return const Center(child: Text(&#39;No data available.&#39;));<br>        } else {<br>          // Display the paginated data<br>          final items = snapshot.data;<br>          return ListView(<br>            controller: _scrollController,<br>            children: [<br>              GridView.builder(<br>                shrinkWrap: true,<br>                physics: const NeverScrollableScrollPhysics(),<br>                itemCount: items!.length,<br>                itemBuilder: (context, index) {<br>                  return Item(img: items[index].toString());<br>                },<br>                gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(<br>                    crossAxisCount: 3),<br>              ),<br>              if (_isFetchingData)<br>                const Center(<br>                    child: Padding(<br>                  padding: EdgeInsets.all(8.0),<br>                  child: CircularProgressIndicator(),<br>                )),<br>            ],<br>          );<br>        }<br>      },<br>    );<br>  }<br><br>  @override<br>  void dispose() {<br>    _dataStreamController.close();<br>    //we do not have control cover the _scrollController so it should not be disposed here<br>    // _scrollController.dispose();<br>    super.dispose();<br>  }<br>}</pre><h4>fetch_data.dart</h4><pre>import &#39;dart:convert&#39;;<br>import &#39;package:http/http.dart&#39;;<br><br>Future&lt;List&lt;String&gt;&gt; fetchData(int currentPage, int pageSize) async {<br>  final Uri uri = Uri.parse(&quot;https://api.pexels.com/v1/search&quot;);<br>  const String API_KEY = &quot;Your_Api_Key&quot;; // Replace with your API key<br><br>  final Map&lt;String, String&gt; headers = {<br>    &quot;Authorization&quot;: API_KEY,<br>  };<br><br>  final Map&lt;String, String&gt; params = {<br>    &quot;query&quot;: &#39;cat&#39;,<br>    &quot;per_page&quot;: pageSize.toString(),<br>    &quot;page&quot;: currentPage.toString(),<br>  };<br><br>  final Uri finalUri = uri.replace(queryParameters: params);<br>  final response = await get(<br>    finalUri,<br>    headers: headers,<br>  );<br><br>  if (response.statusCode == 200) {<br>    final jsonResponse = jsonDecode(response.body);<br>    final photos = jsonResponse[&quot;photos&quot;] as List&lt;dynamic&gt;;<br><br>    final items = &lt;String&gt;[];<br>    for (final photo in photos) {<br>      items.add(photo[&quot;src&quot;][&quot;medium&quot;]);<br>    }<br>    return items;<br>  } else {<br>    throw Exception(&#39;Failed to fetch data&#39;);<br>  }<br>}</pre><h3>Conclusion</h3><p>Enhancing your infinite scroll pagination with loading indicators ensures a smoother and more enjoyable user experience. Users can clearly see when new data is being fetched, making your app feel more responsive and user-friendly.</p><p>By converting a StreamBuilder into a powerful pagination tool and adding loading indicators, you can keep users engaged and provide them with fresh content without interruptions. Still there are better option for this but give this approach a try in your next Flutter project, and watch your app’s user experience soar to new heights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bc145c96958" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>