<?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 Ravi Pai on Medium]]></title>
        <description><![CDATA[Stories by Ravi Pai on Medium]]></description>
        <link>https://medium.com/@ravi-pai?source=rss-86b7e6ed57f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZDMaRizvruLHK19VCoWlhA.png</url>
            <title>Stories by Ravi Pai on Medium</title>
            <link>https://medium.com/@ravi-pai?source=rss-86b7e6ed57f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 12:33:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravi-pai/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[Flutter’s Rendering Pipeline: The Architecture Most Devs Skip, Then Regret]]></title>
            <link>https://medium.com/@ravi-pai/flutters-rendering-pipeline-the-architecture-most-devs-skip-then-regret-c8dca62d759f?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8dca62d759f</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 16 Feb 2026 07:31:01 GMT</pubDate>
            <atom:updated>2026-02-16T07:31:01.266Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7_98vBmPk8DgyQKm.png" /><figcaption>Flutter Docs</figcaption></figure><p>I started learning <strong>Flutter’s Rendering Pipeline</strong> for a very simple reason.</p><p>Flutter yelled at me.</p><p>Not literally, but you know the errors:</p><blockquote><em>“RenderBox was not laid out”<br> “Vertical viewport was given unbounded height”</em></blockquote><p>At first, I did what every developer does — <strong>ignored it and tried random fixes</strong>.<br> Wrap with Expanded.<br> Then SizedBox.<br> Then Container.<br> Then pray.</p><p>But one day I thought:</p><blockquote><em>“Maybe Flutter isn’t angry. Maybe it’s just… explaining something.”</em></blockquote><p>That curiosity took me down the rabbit hole, and what I found was not just a pipeline — it was <strong>how Flutter actually thinks</strong>.</p><p>This article is that journey.</p><h4>The Pipeline at a Glance</h4><p>Before we zoom in, here’s the full flow I wish someone had shown me earlier:</p><pre>Widgets<br>   ↓<br>Elements<br>   ↓<br>Render Objects<br>   ↓<br>Layout<br>   ↓<br>Paint<br>   ↓<br>Compositing<br>   ↓<br>Rasterization (Pixels)</pre><h4>The First Realisation: Widgets Are Not the UI</h4><p>This hit me early and hit me hard.</p><p>Flutter does <strong>not</strong> draw widgets on the screen.</p><p>Widgets are just <strong>descriptions</strong>.<br> They are temporary, immutable, and disappear faster than my motivation on Monday mornings.</p><p>Every time build() runs, Flutter creates a <strong>new widget tree</strong>, reads it, and throws it away.</p><p>At first this sounds insane.</p><p>Then you realise: this is exactly why Flutter is fast.</p><h4>Step 1: Widget Tree — The Idea Phase</h4><p>This is where <em>you</em> live.</p><p>You write widgets.<br>Flutter reads them like instructions.</p><p>Widgets say things like:</p><blockquote><em>“I want padding.”<br> “I want to be blue.”<br> “I want to sit in a column.”</em></blockquote><p>Flutter nods politely and moves on.</p><p>Widgets don’t store state.<br> Widgets don’t measure themselves.<br> Widgets don’t paint.</p><p>They just describe.</p><h4>Step 2: Element Tree — The Part That Remembers</h4><p>Here’s the part I didn’t appreciate enough early on.</p><p>Elements are created from widgets and <strong>stick around</strong>.</p><p>They:</p><ul><li>Keep the connection between old and new widgets</li><li>Hold State objects</li><li>Decide whether something can be reused</li></ul><p>When you call setState(), Flutter doesn’t panic.<br> It rebuilds widgets, compares them with existing elements, and says:</p><blockquote><em>“Relax, most of this is the same.”</em></blockquote><p>This is why rebuilds are cheap and safe.</p><h4>Step 3: Render Tree — Where Flutter Gets Serious</h4><p>This is where things stop being abstract.</p><p>Render objects handle:</p><ul><li>Size</li><li>Position</li><li>Painting logic</li></ul><p>This is also where Flutter becomes very strict.</p><p>Render objects live by one rule:</p><blockquote><strong><em>Constraints go down, sizes go up</em></strong></blockquote><p>Parents tell children how big they’re allowed to be.<br> Children respond with how big they actually are.</p><p>Ignore this rule and Flutter throws those famous layout errors.</p><h3>Step 4: Layout — Measuring Everything</h3><p>During layout, Flutter walks the render tree and asks every object:</p><blockquote><em>“How big are you?”<br> “Where do you live on the screen?”</em></blockquote><p>This happens <strong>top-down</strong>.</p><p>This is also why:</p><ul><li>Infinite height breaks things</li><li>Expanded needs bounded parents</li><li>Scroll views don’t like guessing sizes</li></ul><p>Once I understood this phase, layout bugs stopped feeling random.</p><h3>Step 5: Paint — Drawing Without Pixels</h3><p>Next comes painting.</p><p>Render objects now record <strong>draw commands</strong>:</p><ul><li>Draw text here</li><li>Draw rectangle there</li><li>Apply shadow</li></ul><p>Important detail:<br>Flutter still hasn’t drawn pixels.</p><p>It’s just preparing instructions.</p><p>Think of it like planning a painting, not actually painting yet.</p><h3>Step 6: Compositing — Organising Layers</h3><p>Now Flutter groups painted content into <strong>layers</strong>.</p><p>Opacity, transforms, clips — they all create layers.</p><p>This is where performance lives.</p><p>Using RepaintBoundary tells Flutter:</p><blockquote><em>“This part changes a lot. Don’t repaint everything else.”</em></blockquote><p>Once I learned this, janky animations started making sense.</p><h3>Step 7: Rasterization — Pixels, Finally</h3><p>At the end, Flutter hands everything to the engine</p><ul><li>Takes layers</li><li>Uses the GPU</li><li>Converts instructions into pixels</li></ul><p>This is the moment your UI becomes real.</p><p>Flutter errors are not random. They are <strong>pipeline complaints</strong>.</p><p>Flutter isn’t yelling — it’s reporting <em>exactly</em> where the rules were broken.</p><p>Once you understand the rendering pipeline, something shifts:</p><p>Errors start explaining themselves instead of feeling cryptic.<br>Performance issues become predictable instead of mysterious.<br>CustomPaint stops feeling scary and starts feeling logical.</p><p>Flutter isn’t hard.</p><p>Flutter is just <strong>very honest about how it works</strong>.</p><p>If you found this helpful, give it a <strong>clap</strong> — it tells the algorithm I’m not just talking to myself. Share it with your dev circle, and if you enjoy these breakdowns, a <strong>follow</strong> really helps and keeps me writing. Until next time.</p><ul><li><a href="https://medium.com/@ravi-pai/why-const-widgets-still-rebuild-in-flutter-a-misunderstood-optimization-ae5acfcd11dd">Why const Widgets Still Rebuild in Flutter — A Misunderstood Optimization</a></li><li><a href="https://medium.com/@ravi-pai/hidden-flutter-widgets-that-make-your-app-feel-senior-level-polished-f400c013d07a">Hidden Flutter Widgets That Make Your App Feel Senior-Level Polished</a></li><li><a href="https://medium.com/@ravi-pai/how-a-tiny-3-kb-json-file-brought-my-flutter-app-to-its-knees-87cb9b8bbb35">How a Tiny 3 KB JSON File Brought My Flutter App to Its Knees</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8dca62d759f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why connectivity_plus Wasn’t Enough — And What I Built Instead]]></title>
            <link>https://medium.com/@ravi-pai/why-connectivity-plus-wasnt-enough-and-what-i-built-instead-4f2692e305da?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f2692e305da</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 09 Feb 2026 07:31:00 GMT</pubDate>
            <atom:updated>2026-02-09T07:31:00.913Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why connectivity_plus Wasn’t Enough — And What I Built Instead</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zBdNNxCnJnLRLdBCkSJkXw.png" /></figure><p>You may have used apps or played games where most of them have a <strong>reactive internet check</strong> — when the internet goes, they show a “No Internet” warning, and when it comes back, the warning disappears.</p><p>When I tried to implement the same in Flutter, I realized the usual packages could detect the network type or perform reachability checks, but <strong>none allowed me to show a custom screen and automatically remove it when connectivity returned</strong>.</p><p>This guide explains how I <strong>built </strong><a href="https://pub.dev/packages/connectivity_watcher"><strong>connectivity_watcher</strong></a>, step by step, to solve real internet detection and offline UX in Flutter.</p><h3>The Foundation.</h3><p>I wanted an package that could:</p><ul><li>Detect real internet connectivity, not just network type</li><li>Show a custom offline screen when internet goes down</li><li>Automatically remove the offline screen when internet comes back</li></ul><p>Existing packages could check connectivity but didn’t provide UI handling or recovery features. This meant extra boilerplate and messy code.</p><p>I also came across <strong>heartbeat strategies</strong> to check internet, which are used by popular games like Clash of Clans, PUBG, and others to maintain real-time connectivity.</p><h4>Detecting Real Internet</h4><p>Here there were two choices:</p><ul><li>Use an existing package that handles connectivity checks</li><li>Build from scratch</li></ul><p>I decided to <strong>build from scratch</strong> because I wanted a <strong>heartbeat strategy</strong> that checks the internet at regular intervals. I also wanted to allow <strong>custom URLs</strong> for detection, as some VPNs or firewalls might block common endpoints. If no URL is provided, the system falls back to DNS checks using Google or Cloudflare.</p><p>Here is the core class I built for this:</p><pre>import &#39;dart:async&#39;;<br>import &#39;dart:io&#39;;<br>import &#39;dart:ui&#39;;<br>import &#39;package:dio/dio.dart&#39;;<br><br>class StealthInternetChecker {<br>  final Duration checkInterval;<br>  final Duration timeout;<br>  final String? heartbeatUrl;<br>  final List&lt;String&gt; dnsTargets;<br>  final int dnsPort;<br><br>  late final Dio _dio;<br>  late final StreamController&lt;bool&gt; _controller;<br>  bool _lastStatus = false;<br>  Timer? _timer;<br><br>  StealthInternetChecker({<br>    this.heartbeatUrl,<br>    this.checkInterval = const Duration(seconds: 5),<br>    this.timeout = const Duration(seconds: 3),<br>    this.dnsTargets = const [&#39;8.8.8.8&#39;, &#39;1.1.1.1&#39;],<br>    this.dnsPort = 443,<br>  }) {<br>    _dio = Dio(BaseOptions(<br>      connectTimeout: timeout,<br>      receiveTimeout: timeout,<br>      validateStatus: (status) =&gt; status != null &amp;&amp; status &lt; 500,<br>    ));<br><br>    _controller = StreamController&lt;bool&gt;.broadcast(<br>      onListen: _start,<br>      onCancel: _stop,<br>    );<br>  }<br><br>  Stream&lt;bool&gt; get onStatusChange =&gt; _controller.stream;<br><br>  void _start() {<br>    _timer = Timer.periodic(checkInterval, (_) =&gt; _checkInternet());<br>    _checkInternet();<br>  }<br><br>  void _stop() {<br>    _timer?.cancel();<br>    _timer = null;<br>  }<br><br>  Future&lt;void&gt; _checkInternet() async {<br>    bool isConnected = await hasInternet();<br>    if (isConnected != _lastStatus) {<br>      _lastStatus = isConnected;<br>      _controller.add(isConnected);<br>    }<br>  }<br><br>  Future&lt;bool&gt; hasInternet() async {<br>    if (heartbeatUrl != null) {<br>      try {<br>        final response = await _dio.head(heartbeatUrl!);<br>        if (response.statusCode != null) return true;<br>      } catch (e) {}<br>    }<br><br>    return await _checkDnsConnection();<br>  }<br><br>  Future&lt;bool&gt; _checkDnsConnection() async {<br>    try {<br>      final checks = dnsTargets.map((ip) =&gt; _trySocket(ip)).toList();<br>      final results = await Future.wait(checks);<br>      return results.any((success) =&gt; success);<br>    } catch (_) {<br>      return false;<br>    }<br>  }<br><br>  Future&lt;bool&gt; _trySocket(String ip) async {<br>    try {<br>      final socket = await Socket.connect(ip, dnsPort, timeout: timeout);<br>      socket.destroy();<br>      return true;<br>    } catch (_) {<br>      return false;<br>    }<br>  }<br><br>  void dispose() {<br>    _stop();<br>    _controller.close();<br>  }<br>}<br></pre><h4>Ability to Add Custom Widget for No Internet.</h4><p>My second requirement was to <strong>allow developers to pass a custom widget</strong> to show when the internet goes offline. Existing packages did not support this.</p><p>Initially, I thought of using a Stack to overlay the widget above the entire widget tree. But the problem was that <strong>every internet check would trigger a rebuild of the entire tree</strong>, which is inefficient.</p><p>To solve this, I used <strong>OverlayEntry</strong> to insert the custom widget dynamically and remove it when the connection comes back. To do this, we need a BuildContext to insert the overlay. A common approach is to use GlobalKey&lt;NavigatorState&gt; and assign it to MaterialApp.</p><p>For users who only want a <strong>dialog or snackbar</strong>, I included those options as well, so you can choose what fits your app best.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*zKu8ZcHbG74rgcA2U_-_8w.gif" /></figure><pre>ZoConnectivityWrapper(<br>  connectivityStyle: NoConnectivityStyle.CUSTOM,<br>  offlineWidget: CustomNoInternetWrapper(<br>    builder: (context) =&gt; CustomNoInternet(),<br>  ),<br>  builder: (context, connectionKey) =&gt; MaterialApp(<br>    navigatorKey: connectionKey,<br>    home: LoginDemo(),<br>  ),<br>);<br></pre><h4>Ability to Check Status Manually</h4><p>Another important requirement was manual internet checks. Sometimes you want to verify the network before making an API call — because nothing says “professional app” like hitting a server only to get a timeout and watching a spinning loader while your users silently judge your life choices. 😅</p><p>I added a method to get the current connectivity status on demand:</p><pre>bool hasInternet = await ZoConnectivityWatcher().isInternetAvailable;</pre><p>This allows developers to check the live status <strong>before performing network-dependent actions</strong> — saving you from explaining to users that “yes, your Wi-Fi looks full, but apparently the internet is taking a nap.”</p><p>connectivity_watcher keeps your Flutter app internet-aware, reactive, and way less dramatic.</p><p>Its powers include:</p><ul><li>Detecting when the internet ghosts you</li><li>Stopping your app from panicking</li><li>Playing nice with your UI</li></ul><p>For more features and secret tricks, check it out on <a href="https://pub.dev/packages/connectivity_watcher">pub.dev.</a> Got a wild idea or improvement? Open an issue — it helps the package improve and gives me a chance to learn something new along the way.</p><ul><li><a href="https://medium.com/easy-flutter/i-saw-a-slick-animated-border-on-the-internet-so-i-made-it-in-flutter-467fd576dd1a">I Saw a Slick Animated Border on the Internet — So I Made It in Flutter</a></li><li><a href="https://medium.com/@ravi-pai/hidden-flutter-widgets-that-make-your-app-feel-senior-level-polished-f400c013d07a">Hidden Flutter Widgets That Make Your App Feel Senior-Level Polished</a></li><li><a href="https://medium.com/@ravi-pai/all-about-gradle-part-1-gradle-basics-every-flutter-dev-must-know-9c1796c77b1d">Gradle Made Simple (Part 1): Gradle Basics Every Flutter Dev Must Know</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f2692e305da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Animation: Building Natural Motion with TweenSequence]]></title>
            <link>https://medium.com/@ravi-pai/mastering-animation-building-natural-motion-with-tweensequence-2d6af25bb6e3?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d6af25bb6e3</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 07:31:01 GMT</pubDate>
            <atom:updated>2026-02-02T07:31:01.828Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmLVtEn8-L0OzzOYsLYubw.png" /></figure><p>When we work with animations, we usually just define a <strong>start</strong> and an <strong>end</strong>, and call it a day. The job gets done… but the result often feels <strong>robotic</strong>.</p><p>Because in real life, motion isn’t a straight line.It accelerates. It slows down. It overshoots. It settles.</p><p>Kind of like life — not a straight path, just a beautiful mix of ups and downs.</p><p>That’s where <strong>TweenSequence</strong> quietly turns your animations from<br> <strong>“meh”</strong> → <strong>“wait… that feels nice.”</strong></p><h4>So… What <em>Is</em> TweenSequence Exactly?</h4><p>A normal Tween does one very simple job: it moves a value from <strong>A</strong> to <strong>B</strong> over time.<br>And honestly, most of the time, that’s enough.</p><p>But the moment you want an animation to feel <em>natural</em>, a single tween starts to fall short.<br> Because real motion is rarely a straight line. It speeds up, slows down, overshoots a little, and then settles.</p><p>That’s where TweenSequence comes in.</p><p>Instead of describing motion as <em>one step</em>, TweenSequence lets you describe it as <strong>a series of small steps</strong> that play one after another. Each step is still just a normal tween, but together they form a motion that feels intentional rather than robotic.</p><pre>TweenSequence&lt;double&gt;([<br>  TweenSequenceItem(<br>    tween: Tween(begin: 0.9, end: 1.05),<br>    weight: 70,<br>  ),<br>  TweenSequenceItem(<br>    tween: Tween(begin: 1.05, end: 1.0),<br>    weight: 30,<br>  ),<br>]);</pre><p>At first glance, TweenSequence looks intimidating.<br>In reality, it’s just a <strong>list of tweens</strong> played one after another.</p><p>Each TweenSequenceItem has <strong>two parameters</strong>:</p><ul><li><strong>tween</strong> → defines <em>what value changes during this phase</em> of the animation.</li><li><strong>weight</strong> → defines <em>how much of the total animation time this phase gets</em>.</li></ul><h3>Animation Without TweenSequence (Robotic Motion)</h3><p>This is the classic “linear” animation.<br> It works, but feels stiff because it moves straight from start to end without any natural overshoot or settle.</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class WithoutTweenSequenceCard extends StatefulWidget {<br>  const WithoutTweenSequenceCard({super.key});<br><br>  @override<br>  State&lt;WithoutTweenSequenceCard&gt; createState() =&gt;<br>      _WithoutTweenSequenceCardState();<br>}<br><br>class _WithoutTweenSequenceCardState extends State&lt;WithoutTweenSequenceCard&gt;<br>    with SingleTickerProviderStateMixin {<br>  late AnimationController _controller;<br>  late Animation&lt;double&gt; _scale;<br><br>  @override<br>  void initState() {<br>    super.initState();<br><br>    _controller = AnimationController(<br>      vsync: this,<br>      duration: const Duration(milliseconds: 500),<br>    );<br><br>    _scale = Tween&lt;double&gt;(begin: 0.9, end: 1.0).animate(<br>      CurvedAnimation(parent: _controller, curve: Curves.easeOut),<br>    );<br><br>    _controller.forward();<br>  }<br><br>  @override<br>  void dispose() {<br>    _controller.dispose();<br>    super.dispose();<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return AnimatedBuilder(<br>      animation: _scale,<br>      builder: (_, child) {<br>        return Transform.scale(<br>          scale: _scale.value,<br>          child: child,<br>        );<br>      },<br>      child: _buildCard(<br>        title: &#39;Without TweenSequence&#39;,<br>        color: Colors.redAccent,<br>      ),<br>    );<br>  }<br>}<br><br>=<br>Widget _buildCard({required String title, required Color color}) {<br>  return Container(<br>    width: 220,<br>    height: 100,<br>    alignment: Alignment.center,<br>    decoration: BoxDecoration(<br>      color: color,<br>      borderRadius: BorderRadius.circular(16),<br>      boxShadow: const [<br>        BoxShadow(<br>          color: Colors.black26,<br>          blurRadius: 10,<br>          offset: Offset(0, 6),<br>        ),<br>      ],<br>    ),<br>    child: Text(<br>      title,<br>      textAlign: TextAlign.center,<br>      style: const TextStyle(<br>        color: Colors.white,<br>        fontSize: 16,<br>        fontWeight: FontWeight.bold,<br>      ),<br>    ),<br>  );<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yoC9-APbVlur9OUIxsYObQ.gif" /></figure><h4>Animation With TweenSequence</h4><p>Here we use TweenSequence to give the animation <strong>overshoot + settle</strong>.<br>This makes the card feel <strong>alive and polished</strong>, like a real-world motion.</p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>class WithTweenSequenceCard extends StatefulWidget {<br>  const WithTweenSequenceCard({super.key});<br><br>  @override<br>  State&lt;WithTweenSequenceCard&gt; createState() =&gt; _WithTweenSequenceCardState();<br>}<br><br>class _WithTweenSequenceCardState extends State&lt;WithTweenSequenceCard&gt;<br>    with SingleTickerProviderStateMixin {<br>  late AnimationController _controller;<br>  late Animation&lt;double&gt; _scale;<br><br>  @override<br>  void initState() {<br>    super.initState();<br><br>    _controller = AnimationController(<br>      vsync: this,<br>      duration: const Duration(milliseconds: 500),<br>    );<br><br>    _scale = TweenSequence&lt;double&gt;([<br>      TweenSequenceItem(<br>        tween: Tween(begin: 0.9, end: 1.05)<br>            .chain(CurveTween(curve: Curves.easeOut)),<br>        weight: 70,<br>      ),<br>      TweenSequenceItem(<br>        tween: Tween(begin: 1.05, end: 1.0)<br>            .chain(CurveTween(curve: Curves.easeIn)),<br>        weight: 30,<br>      ),<br>    ]).animate(_controller);<br><br>    _controller.forward();<br>  }<br><br>  @override<br>  void dispose() {<br>    _controller.dispose();<br>    super.dispose();<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return AnimatedBuilder(<br>      animation: _scale,<br>      builder: (_, child) {<br>        return Transform.scale(<br>          scale: _scale.value,<br>          child: child,<br>        );<br>      },<br>      child: _buildCard(<br>        title: &#39;With TweenSequence&#39;,<br>        color: Colors.green,<br>      ),<br>    );<br>  }<br>}<br><br><br>Widget _buildCard({required String title, required Color color}) {<br>  return Container(<br>    width: 220,<br>    height: 100,<br>    alignment: Alignment.center,<br>    decoration: BoxDecoration(<br>      color: color,<br>      borderRadius: BorderRadius.circular(16),<br>      boxShadow: const [<br>        BoxShadow(<br>          color: Colors.black26,<br>          blurRadius: 10,<br>          offset: Offset(0, 6),<br>        ),<br>      ],<br>    ),<br>    child: Text(<br>      title,<br>      textAlign: TextAlign.center,<br>      style: const TextStyle(<br>        color: Colors.white,<br>        fontSize: 16,<br>        fontWeight: FontWeight.bold,<br>      ),<br>    ),<br>  );<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6BcoXwYrxFY9WbX7qXuXQ.gif" /></figure><p>With TweenSequence, you can break your animations into phases, add overshoot, settle, or even subtle bounces, and suddenly your UI feels alive. But honestly, this is just the tip of the iceberg.</p><p>So next time your animation feels “meh,” remember: it’s not about moving, it’s about <strong>how you move</strong>. TweenSequence gives you the tools to go beyond “good enough” and make your UI feel deliberate, polished, and, dare I say, alive.</p><p>If this helped, consider sharing it with a fellow dev. For more such finds, hit follow — and until next time, happy Fluttering</p><ul><li><a href="https://medium.com/@ravi-pai/anchored-overlays-in-flutter-the-right-way-yes-there-is-one-900cc0d7f103">Anchored Overlays in Flutter: The Right Way (Yes, There Is One)</a></li><li><a href="https://medium.com/easy-flutter/i-saw-a-slick-animated-border-on-the-internet-so-i-made-it-in-flutter-467fd576dd1a">I Saw a Slick Animated Border on the Internet — So I Made It in Flutter</a></li><li><a href="https://medium.com/@ravi-pai/how-a-tiny-3-kb-json-file-brought-my-flutter-app-to-its-knees-87cb9b8bbb35">How a Tiny 3 KB JSON File Brought My Flutter App to Its Knees</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d6af25bb6e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extracting Widgets in Flutter — When, Why, and How]]></title>
            <link>https://medium.com/@ravi-pai/extracting-widgets-in-flutter-when-why-and-how-ec7483faf473?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec7483faf473</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 07:32:03 GMT</pubDate>
            <atom:updated>2026-01-26T07:32:03.338Z</atom:updated>
            <content:encoded><![CDATA[<h3>Extracting Widgets in Flutter — When, Why, and How</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UO4bKPCUMYNN3Qj-J-A6Ng.png" /></figure><p>If you’ve been writing Flutter for more than a few weeks, chances are you’ve already met <strong>The Giant Build Method</strong>.</p><p>You know exactly which one.</p><p>It starts off innocent enough — a Column here, a Row there, maybe a harmless little Container. Everything feels under control. You’re productive. You’re happy.</p><p>Then one day… you scroll.</p><p>And scroll.</p><p>And scroll again.</p><p>At some point, scrolling stops and bargaining begins:</p><blockquote>“I’ll refactor this later.”</blockquote><p>Spoiler alert: <strong>later never comes</strong>.</p><p>That build() method is now longer than your screen, harder to read than a legal document, and just complex enough that touching it feels risky.</p><p>This article is about <strong>extracting widgets in Flutter</strong> — not as a theory, but as a practical skill. We’ll cover <em>when</em> to extract, <em>why</em> it actually matters, and <em>how</em> to do it using real-world best practices that make sense for <strong>junior, mid-level, and senior developers alike</strong>.</p><h4>What Does Extracting a Widget Mean?</h4><p>Extracting a widget simply means taking a part of your UI and moving it into its <strong>own widget class</strong>, instead of keeping everything inside one massive build() method.</p><p>In short:</p><ul><li>You identify a logical UI section</li><li>You give it a meaningful name</li><li>You turn it into a reusable widget</li></ul><p>This small habit has a <strong>big impact</strong> on readability, performance, and long-term maintainability.</p><h3>Why Extract Widgets? (The Real Reasons)</h3><h4>1. Controlling Rebuilds</h4><p>Flutter rebuilds widgets frequently — and that’s perfectly fine.</p><p>The real problem begins when <strong>everything rebuilds</strong>, even though only a small part of the UI actually changed. This usually happens when state lives <strong>too high</strong> in the widget tree.</p><p>When setState() is called, Flutter reruns the build() method of that widget. If that widget represents an entire screen, then a tiny change — like typing into a text field — can cause the whole screen to rebuild.</p><pre>class ProfileScreen extends StatefulWidget {<br>  @override<br>  State&lt;ProfileScreen&gt; createState() =&gt; _ProfileScreenState();<br>}<br><br>class _ProfileScreenState extends State&lt;ProfileScreen&gt; {<br>  String name = &#39;&#39;;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Column(<br>      children: [<br>        UserHeader(),<br>        TextField(<br>          onChanged: (value) {<br>            setState(() =&gt; name = value);<br>          },<br>        ),<br>        Footer(), <br>      ],<br>    );<br>  }<br>}</pre><p>Here, every keystroke triggers setState(), which causes:</p><ul><li>ProfileScreen.build() to run again</li><li>UserHeader and Footer to rebuild</li><li>Extra work for Flutter with no visual benefit</li></ul><p>This behavior is expected — but avoidable.</p><h3>The Solution: Extract Widgets and Localize State</h3><p>By extracting the changing part into its own widget and moving the state closer to where it’s used, you limit the rebuild scope.</p><pre>class ProfileScreen extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return const Column(<br>      children: [<br>        UserHeader(),<br>        NameInput(),<br>        Footer(),<br>      ],<br>    );<br>  }<br>}<br><br>class NameInput extends StatefulWidget {<br>  const NameInput({super.key});<br><br>  @override<br>  State&lt;NameInput&gt; createState() =&gt; _NameInputState();<br>}<br><br>class _NameInputState extends State&lt;NameInput&gt; {<br>  String name = &#39;&#39;;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return TextField(<br>      onChanged: (value) {<br>        setState(() =&gt; name = value);<br>      },<br>    );<br>  }<br>}<br></pre><h3>Why This Works</h3><ul><li>Typing now rebuilds <strong>only </strong><strong>NameInput</strong></li><li>Static widgets remain untouched</li><li>Flutter does less work per frame</li><li>UI and state are clearly decoupled</li></ul><p><strong>Best practices for rebuild control:</strong></p><ul><li>Keep state as low as possible in the widget tree</li><li>Extract widgets that don’t depend on changing state</li><li>Use const constructors wherever possible</li></ul><h3>2. Reusability Without Copy-Paste</h3><p>Copy-pasting UI is usually a sign that extraction is overdue.</p><p>When UI and state are tightly coupled, reuse becomes painful.<br>When they’re decoupled, reuse becomes effortless.</p><pre>@override<br>Widget build(BuildContext context) {<br>  return Scaffold(<br>    body: Center(<br>      child: ElevatedButton(<br>        onPressed: () {<br>          // submit form<br>        },<br>        style: ElevatedButton.styleFrom(<br>          padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),<br>          shape: RoundedRectangleBorder(<br>            borderRadius: BorderRadius.circular(8),<br>          ),<br>        ),<br>        child: const Text(<br>          &#39;Submit&#39;,<br>          style: TextStyle(fontSize: 16),<br>        ),<br>      ),<br>    ),<br>  );<br>}</pre><p>With Widget Extraction</p><pre>@override<br>Widget build(BuildContext context) {<br>  return const Scaffold(<br>    body: Center(<br>      child: PrimaryButton(<br>        label: &#39;Submit&#39;,<br>        onPressed: submitForm,<br>      ),<br>    ),<br>  );<br>}<br><br>class PrimaryButton extends StatelessWidget {<br>  final String label;<br>  final VoidCallback onPressed;<br><br>  const PrimaryButton({<br>    super.key,<br>    required this.label,<br>    required this.onPressed,<br>  });<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return ElevatedButton(<br>      onPressed: onPressed,<br>      style: ElevatedButton.styleFrom(<br>        padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),<br>        shape: RoundedRectangleBorder(<br>          borderRadius: BorderRadius.circular(8),<br>        ),<br>      ),<br>      child: Text(<br>        label,<br>        style: const TextStyle(fontSize: 16),<br>      ),<br>    );<br>  }<br>}</pre><p><strong>Best practices:</strong></p><ul><li>Extract widgets that appear in more than one place</li><li>Design widgets with configurable parameters instead of hardcoded values</li><li>Keep widgets flexible, but focused on a single responsibility</li></ul><p>Today it’s used once. Tomorrow it’s used everywhere.</p><p>Future you — and your teammates — will be grateful you extracted it early.</p><h3>A Simple Decision Checklist</h3><p>Before extracting a widget, ask yourself:</p><ul><li>Does this improve readability?</li><li>Can this be reused?</li><li>Does this help with performance or testing?</li><li>Can I clearly name this widget?</li></ul><p>If at least <strong>two answers are yes</strong>, extract it.</p><p>Extracting widgets isn’t about flexing architecture or creating 69 files for one screen — it’s about writing code you’ll still understand months later, keeping rebuilds predictable, reducing bugs, and protecting your mental health. Flutter loves small, focused, well-named widgets, and so will future you. If this helped, give it a clap — it tells the algorithm I’m not yelling into the void. Share it with your dev friends, drop a follow if you enjoy these breakdowns Until Next Time.</p><ul><li><a href="https://medium.com/easy-flutter/i-saw-a-slick-animated-border-on-the-internet-so-i-made-it-in-flutter-467fd576dd1a">I Saw a Slick Animated Border on the Internet — So I Made It in Flutter</a></li><li><a href="https://medium.com/@ravi-pai/want-to-code-like-a-senior-flutter-dev-try-these-5-extensions-6097374a64fe">Want to Code Like a Senior Flutter Dev? Try These 5 Extensions!(Part 1)</a></li><li><a href="https://medium.com/@ravi-pai/common-mistakes-to-avoid-while-using-completer-in-flutter-e6f766689c61">Common Mistakes to Avoid While Using Completer in Flutter!!</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec7483faf473" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why const Widgets Still Rebuild in Flutter — A Misunderstood Optimization]]></title>
            <link>https://medium.com/@ravi-pai/why-const-widgets-still-rebuild-in-flutter-a-misunderstood-optimization-ae5acfcd11dd?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae5acfcd11dd</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 07:31:59 GMT</pubDate>
            <atom:updated>2026-01-19T07:31:59.940Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why const Widgets Still Rebuild in Flutter — A Misunderstood Optimization</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sVKkAxGdRj2yAC2eOuaYlA.png" /></figure><p>If you’ve spent any time in Flutter land, you’ve probably heard this legendary piece of advice: <em>“Just make it </em><em>const. It won’t rebuild.”</em> It’s usually said with the same confidence as “Have you tried turning it off and on again?” And for a while, you believe it. You sprinkle const everywhere, feel productive, and then open Flutter DevTools… only to see widgets still rebuilding.</p><p>In Flutter, a rebuild is not the villain people make it out to be. A rebuild simply means the build() method runs again — nothing more. Flutter does this constantly and is extremely good at it. What actually impacts performance is the extra work <em>after</em> a rebuild, like layout, paint, and compositing — the kind of work that would make your phone’s fan spin… if phones had fans.</p><p>This is also why you often hear <em>“don’t put heavy logic inside the </em><em>build() method.”</em> Since build() can run frequently, expensive calculations there get repeated more than you expect.</p><p>Let’s look at a small example. At first glance, you might think both variables below are just different objects holding the same value, so neither pair should be identical. That assumption feels reasonable — and it’s also only half right.</p><pre>void main() {<br>  final a = Text(&#39;Hello&#39;);<br>  final b = Text(&#39;Hello&#39;);<br><br>  print(identical(a, b)); <br><br>  const c = Text(&#39;Hello&#39;);<br>  const d = Text(&#39;Hello&#39;);<br><br>  print(identical(c, d)); <br>}</pre><p>When you run this, the final case prints false because each Text(&#39;Hello&#39;) is created at runtime, resulting in two separate widget instances. Even though they look the same, they are not the same object. The const case, however, prints true. That’s because const widgets are created at compile time and cached by Dart, allowing the same instance to be reused wherever it appears.</p><p>Now let’s look at a more realistic example — the kind that makes developers say, <em>“But… it’s </em><em>const and it’s still rebuilding?”</em></p><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return const MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>      home: CounterPage(),<br>    );<br>  }<br>}<br><br>class CounterPage extends StatefulWidget {<br>  const CounterPage({super.key});<br><br>  @override<br>  State&lt;CounterPage&gt; createState() =&gt; _CounterPageState();<br>}<br><br>class _CounterPageState extends State&lt;CounterPage&gt; {<br>  int count = 0;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    debugPrint(&#39;CounterPage build&#39;);<br><br>    return Scaffold(<br>      appBar: AppBar(<br>        title: const Text(&#39;Const Rebuild Demo&#39;),<br>      ),<br>      body: Center(<br>        child: Column(<br>          mainAxisSize: MainAxisSize.min,<br>          children: [<br>            Text(<br>              &#39;Count: $count&#39;,<br>              style: const TextStyle(fontSize: 24),<br>            ),<br>            const SizedBox(height: 16),<br>            const Text(<br>              &#39;I am const,&#39;,<br>              style: TextStyle(fontSize: 18),<br>            ),<br>            const SizedBox(height: 24),<br>            ElevatedButton(<br>              onPressed: () {<br>                setState(() {<br>                  count++;<br>                });<br>              },<br>              child: const Text(&#39;Increment&#39;),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Tap the button a few times and watch the console. You’ll see CounterPage build printed every time, even though one of the widgets is clearly marked const. This is usually where the confusion begins. Many developers expect const Text(&#39;I am const&#39;) to magically opt out of rebuilds altogether — but Flutter never promised that.</p><p>What’s actually happening is much simpler (and smarter). setState rebuilds the parent — that’s expected behavior. Flutter then compares the old widget tree with the new one. The dynamic Text(&#39;Count: $count&#39;) changes and gets updated, while the const text is recognized as the same old widget and quietly reused. The widget rebuilt, but Flutter skipped the expensive layout and paint work.</p><p>So the next time someone says <em>“just use </em><em>const, it skips rebuilds”</em>, remember: that’s only half the truth. const doesn’t stop rebuilds — it stops <strong>wasted work</strong>. And now you know why 😉</p><p>If you found this helpful, give it a <strong>clap</strong> — it tells the algorithm I’m not just talking to myself. Share it with your dev circle, and if you enjoy these breakdowns, a <strong>follow</strong> really helps and keeps me writing. Until next time.</p><ul><li><a href="https://medium.com/@ravi-pai/how-a-tiny-3-kb-json-file-brought-my-flutter-app-to-its-knees-87cb9b8bbb35">How a Tiny 3 KB JSON File Brought My Flutter App to Its Knees</a></li><li><a href="https://medium.com/@ravi-pai/the-one-flutter-trick-that-made-my-messy-code-instantly-clean-guard-clauses-4c186c112064">The One Flutter Trick That Made My Messy Code Instantly Clean: Guard Clauses</a></li><li><a href="https://medium.com/@ravi-pai/most-dart-devs-misunderstand-how-await-works-are-you-one-of-them-975e9d6f9ccd">Most Dart Devs Misunderstand How await Works — Are You One of Them?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae5acfcd11dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parallax in Flutter: How It Works, Why It’s Tricky, and How Flow Makes It Elegant]]></title>
            <link>https://medium.com/easy-flutter/parallax-in-flutter-how-it-works-why-its-tricky-and-how-flow-makes-it-elegant-1da3c96c9cae?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1da3c96c9cae</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 07:32:45 GMT</pubDate>
            <atom:updated>2026-01-17T00:09:46.721Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s be honest. A plain scrolling list is functional…but it also screams <em>“I stopped caring after it worked.”</em></p><p>Parallax scrolling is one of those tiny details that instantly upgrades your app from<br> <strong>“It works”</strong> → <strong>“Oh… this feels nice.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxRIUHf-pMImEXFSLeFMtg.png" /></figure><p>When I tried implementing parallax in Flutter, I did what most of us do.</p><p>I listened to the scroll controller.<br>I translated the widget.</p><p>The result?<br>A slightly janky, “almost smooth but not quite” animation that felt more <em>haunted</em> than polished.</p><p>The problem wasn’t Flutter — it was my approach.<br>Listening to scroll updates and manually translating widgets <strong>works</strong>, but it fights Flutter’s rendering pipeline instead of working with it.</p><p>That’s when I stumbled upon Flutter’s official parallax <a href="https://docs.flutter.dev/cookbook/effects/parallax-scrolling">article</a>.<br>And honestly — it completely changed the trajectory of my implementation.</p><p>The key realization was this:</p><blockquote><em>Don’t move widgets during scroll.<br></em><strong><em>Control how they’re painted instead.</em></strong></blockquote><p>The article uses Flow and a FlowDelegate to tie parallax directly to the paint phase, eliminating unnecessary rebuilds and keeping everything perfectly in sync with scrolling.</p><p>Most of the code in this article — including the FlowDelegate approach you will see — is heavily inspired by that official recipe. I didn’t reinvent the wheel here. I just understood <strong>why the wheel works</strong> and adapted it for real-world use cases like horizontal scrolling and reusable components.</p><h4>Let’s Get Started:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52Gtn9g2fRfwLcJw3lxMYA.gif" /></figure><p>This parallax effect is built using Flutter’s Flow widget and a custom FlowDelegate.</p><p>Instead of <strong>moving widgets during scroll</strong> (which causes jank), we let Flutter <strong>repaint the image</strong> based on the scroll position. This keeps scrolling smooth and perfectly in sync.</p><h4>The Core Idea</h4><ol><li>Get the current scroll position</li><li>Find where a list item sits inside the viewport</li><li>Move the background image slightly based on that position</li></ol><p>That’s it.</p><h4>FlowDelegate</h4><p>FlowDelegate lets you control <strong>how children are painted</strong>, not how they’re laid out.</p><p>That’s the key difference.</p><p>Parallax doesn’t need layout changes — it needs <strong>paint-time movement</strong>.</p><p>This is why this approach feels smooth instead of janky.</p><pre>class ZoParallaxFlowDelegate extends FlowDelegate {<br>  final ScrollableState scrollable;<br>  final BuildContext listItemContext;<br>  final GlobalKey backgroundImageKey;<br>  final Axis scrollDirection;<br><br>  ZoParallaxFlowDelegate({<br>    required this.scrollable,<br>    required this.listItemContext,<br>    required this.backgroundImageKey,<br>    required this.scrollDirection,<br>  }) : super(repaint: scrollable.position);</pre><ul><li><strong>scrollable</strong><br> Knows <em>how far</em> we’ve scrolled and <em>how big</em> the viewport is.</li><li><strong>listItemContext</strong><br> <em>“Where exactly is THIS item on the screen right now?” </em>and Obviously…<br> to perform the <strong>famous RenderBox dance.</strong></li><li><strong>backgroundImageKey</strong><br> We measure the real size of component.</li><li><strong>scrollDirection</strong><br> Tells us —vertical or horizontal scrolling.</li></ul><h4>Fixing Child Constraints.</h4><p>Parallax only works if the background is <strong>larger than the visible area</strong> along the scroll direction.</p><p>To create that extra space, FlowDelegate gives us a hook called <strong>getConstraintsForChild</strong>. This method lets us control how the background is sized <strong>before</strong> it’s painted.</p><pre>@override<br>BoxConstraints getConstraintsForChild(int i, BoxConstraints constraints) {<br>  if (scrollDirection == Axis.horizontal) {<br>    return BoxConstraints.tightFor(height: constraints.maxHeight);<br>  } else {<br>    return BoxConstraints.tightFor(width: constraints.maxWidth);<br>  }<br>}</pre><p><strong>Vertical scroll (</strong><strong>Axis.vertical)</strong></p><ul><li>Image width is locked to the list item.</li><li>Extra height is allowed for vertical movement.</li></ul><p><strong>Horizontal scroll (</strong><strong>Axis.horizontal)</strong></p><ul><li>Image height is locked to the list item.</li><li>Extra width is allowed for horizontal movement.</li></ul><h4>Measuring Real Positions.</h4><p>This is where the <strong>key</strong> and <strong>context</strong> you passed earlier finally shine.</p><p>Widgets in Flutter are polite — they don’t know their exact pixel positions. They only know their place in the widget tree.</p><p>Enter <strong>RenderBox</strong>: the no-nonsense, truth-telling object of the Flutter world. It knows exactly <strong>where your widget sits on the screen</strong>.</p><p>For parallax, we go straight to the source:</p><ul><li>Use the listItemContext to get its RenderBox</li><li>Use the backgroundImageKey to get the image’s RenderBox</li></ul><h4>Axis Difference</h4><ul><li><strong>Horizontal</strong> → track dx</li><li><strong>Vertical</strong> → track dy</li></ul><p>Now, armed with these pixel-perfect measurements, we can calculate the scroll fraction and slide the background <strong>precisely</strong>, with <strong>no guesswork, no jank, and no awkward half-moves</strong>.</p><pre>final scrollableBox =<br>    scrollable.context.findRenderObject() as RenderBox;<br>final listItemBox =<br>    listItemContext.findRenderObject() as RenderBox;<br>final listItemOffset = listItemBox.localToGlobal(<br>  scrollDirection == Axis.horizontal<br>      ? listItemBox.size.topCenter(Offset.zero)<br>      : listItemBox.size.centerLeft(Offset.zero),<br>  ancestor: scrollableBox,<br>);</pre><h4>Turning Pixels Into a Scroll Percentage &amp; Mapping It to Alignment.</h4><p>Once we know <strong>where the list item is on screen</strong>, we convert that pixel position into a <strong>scroll fraction</strong> (0.0 → entering, 0.5 → centered, 1.0 → leaving).</p><blockquote><em>If you’ve ever used </em><em>Alignment.center (or </em><em>Alignment.topLeft), internally it’s just </em><strong><em>x and y values</em></strong><em> between -1 and 1.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OhJj-4o1mfP_T1HVDv7AA.png" /></figure><p>Flutter alignments use <strong>-1 to 1</strong>, not 0–1, so we map the fraction:</p><pre>final alignment = scrollDirection == Axis.horizontal<br>        ? Alignment(scrollFraction * 2 - 1, 0)<br>        : Alignment(0, scrollFraction * 2 - 1);</pre><h4>The Actual Parallax Movement</h4><p>All the calculations, alignments, and measurements are great… but the real magic happens when we <strong>actually move the background</strong>.</p><p>This is where the scroll fraction, alignment, and inscribe come together to <strong>create the illusion of depth</strong>. The list item stays put, but the background slides slightly — and voilà, parallax!</p><pre>context.paintChild(<br>  0,<br>  transform: Transform.translate(<br>    offset: Offset(<br>      scrollDirection == Axis.horizontal ? childRect.left : 0,<br>      scrollDirection == Axis.vertical ? childRect.top : 0,<br>    ),<br>  ).transform,<br>);</pre><p><strong>Full Code</strong></p><pre>import &#39;package:flutter/widgets.dart&#39;;<br><br>class ZoParallaxItem extends StatelessWidget {<br>  ZoParallaxItem({<br>    super.key,<br>    required this.child,<br>    required this.scrollDirection,<br>    this.borderRadius,<br>  });<br><br>  final Widget child;<br>  final Axis scrollDirection;<br>  final GlobalKey _key = GlobalKey();<br>  final BorderRadiusGeometry? borderRadius;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return ClipRRect(<br>      borderRadius: borderRadius ?? BorderRadius.zero,<br>      child: ZoParallaxWidget(<br>        backgroundKey: _key,<br>        scrollDirection: scrollDirection,<br>        child: Container(key: _key, child: child),<br>      ),<br>    );<br>  }<br>}<br><br>class ZoParallaxWidget extends StatelessWidget {<br>  const ZoParallaxWidget({<br>    super.key,<br>    required this.backgroundKey,<br>    required this.child,<br>    this.scrollDirection = Axis.horizontal,<br>  });<br><br>  final GlobalKey backgroundKey;<br>  final Widget child;<br>  final Axis scrollDirection;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Flow(<br>      delegate: ZoParallaxFlowDelegate(<br>        scrollable: Scrollable.of(context),<br>        listItemContext: context,<br>        backgroundImageKey: backgroundKey,<br>        scrollDirection: scrollDirection,<br>      ),<br>      children: [child],<br>    );<br>  }<br>}<br><br>class ZoParallaxFlowDelegate extends FlowDelegate {<br>  final ScrollableState scrollable;<br>  final BuildContext listItemContext;<br>  final GlobalKey backgroundImageKey;<br>  final Axis scrollDirection;<br><br>  ZoParallaxFlowDelegate({<br>    required this.scrollable,<br>    required this.listItemContext,<br>    required this.backgroundImageKey,<br>    required this.scrollDirection,<br>  }) : super(repaint: scrollable.position);<br><br>  @override<br>  BoxConstraints getConstraintsForChild(int i, BoxConstraints constraints) {<br>    if (scrollDirection == Axis.horizontal) {<br>      return BoxConstraints.tightFor(height: constraints.maxHeight);<br>    } else {<br>      return BoxConstraints.tightFor(width: constraints.maxWidth);<br>    }<br>  }<br><br>  @override<br>  void paintChildren(FlowPaintingContext context) {<br>    final scrollableBox = scrollable.context.findRenderObject() as RenderBox;<br>    final listItemBox = listItemContext.findRenderObject() as RenderBox;<br><br>    // Calculate position relative to the scrollable area<br>    final listItemOffset = listItemBox.localToGlobal(<br>      scrollDirection == Axis.horizontal<br>          ? listItemBox.size.topCenter(Offset.zero)<br>          : listItemBox.size.centerLeft(Offset.zero),<br>      ancestor: scrollableBox,<br>    );<br><br>    final viewportDimension = scrollable.position.viewportDimension;<br><br>    // Determine scroll fraction based on the active axis<br>    final scrollFraction =<br>        (scrollDirection == Axis.horizontal<br>                ? listItemOffset.dx / viewportDimension<br>                : listItemOffset.dy / viewportDimension)<br>            .clamp(0.0, 1.0);<br><br>    // Create alignment (-1 to 1)<br>    final alignment = scrollDirection == Axis.horizontal<br>        ? Alignment(scrollFraction * 2 - 1, 0)<br>        : Alignment(0, scrollFraction * 2 - 1);<br><br>    final backgroundSize =<br>        (backgroundImageKey.currentContext!.findRenderObject() as RenderBox)<br>            .size;<br>    final listItemSize = context.size;<br>    final childRect = alignment.inscribe(<br>      backgroundSize,<br>      Offset.zero &amp; listItemSize,<br>    );<br><br>    context.paintChild(<br>      0,<br>      transform: Transform.translate(<br>        offset: Offset(<br>          scrollDirection == Axis.horizontal ? childRect.left : 0,<br>          scrollDirection == Axis.vertical ? childRect.top : 0,<br>        ),<br>      ).transform,<br>    );<br>  }<br><br>  @override<br>  bool shouldRepaint(ZoParallaxFlowDelegate oldDelegate) {<br>    return scrollable != oldDelegate.scrollable ||<br>        listItemContext != oldDelegate.listItemContext ||<br>        backgroundImageKey != oldDelegate.backgroundImageKey ||<br>        scrollDirection != oldDelegate.scrollDirection;<br>  }<br>}</pre><p>Usage.</p><pre>SizedBox(<br>  height: 250,<br>  child: PageView.builder(<br>    controller: PageController(viewportFraction: 0.8),<br>    itemCount: imageUrls.length,<br>    itemBuilder: (context, index) =&gt; Padding(<br>      padding: const EdgeInsets.all(8.0),<br>      child: ZoParallaxItem(<br>        borderRadius: BorderRadius.circular(10),<br>        child: Image.network(<br>          imageUrls[index],<br>          fit: BoxFit.cover,<br>        ),<br>        scrollDirection: Axis.horizontal,<br>      ),<br>    ),<br>  ),<br>)</pre><p>Parallax in Flutter might seem tricky at first, but once you understand how to <strong>measure positions, map alignments, and paint backgrounds</strong>, it becomes a powerful tool to make your UI feel polished and alive.</p><p>If you <strong>learned something new today</strong>, consider <strong>sharing this article</strong> and <strong>following me</strong> for more Flutter hacks, tips, and little discoveries that can level up your apps.</p><p>Also, if you want a <strong>visual walkthrough</strong>, this YouTube tutorial helped me understand it way better: <a href="https://www.youtube.com/watch?v=tgK0u0qwM70&amp;utm_source=chatgpt.com"><strong>Watch here</strong></a>.</p><p>On a side note — I’m working on a <strong>small micro-interaction Flutter package</strong>, and parallax like this is <strong>just one part of it</strong>.. If you’re curious, feel free to check it out <a href="https://pub.dev/packages/zo_micro_interactions">here</a>.Until next time.</p><ul><li><a href="https://medium.com/easy-flutter/i-saw-a-slick-animated-border-on-the-internet-so-i-made-it-in-flutter-467fd576dd1a">I Saw a Slick Animated Border on the Internet — So I Made It in Flutter</a></li><li><a href="https://medium.com/@ravi-pai/rebuilt-reactbits-threads-animation-in-flutter-and-here-s-how-the-math-works-24c32473c025">Rebuilt ReactBits’ Threads Animation in Flutter — and Here’s How the Math Works</a></li><li><a href="https://medium.com/easy-flutter/flutter-magic-build-your-own-particle-system-and-look-like-a-wizard-b1fa55b75c85">Flutter Magic: Build Your Own Particle System (and look like a wizard)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1da3c96c9cae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/easy-flutter/parallax-in-flutter-how-it-works-why-its-tricky-and-how-flow-makes-it-elegant-1da3c96c9cae">Parallax in Flutter: How It Works, Why It’s Tricky, and How Flow Makes It Elegant</a> was originally published in <a href="https://medium.com/easy-flutter">Easy Flutter</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Widgets That Quietly Solve Big UI Problems.]]></title>
            <link>https://medium.com/@ravi-pai/flutter-widgets-that-quietly-solve-big-ui-problems-a971c6b13e37?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a971c6b13e37</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Sun, 04 Jan 2026 19:32:24 GMT</pubDate>
            <atom:updated>2026-01-04T19:32:24.793Z</atom:updated>
            <content:encoded><![CDATA[<p>When you scroll through Flutter tutorials, you’ll see the same widgets over and over again. <em>Container, Column, Row, ListView</em> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aktinez7-HN3xk2F1HKX-A.png" /></figure><p>And that’s fine — everyone starts there.</p><p>But if you spend enough time maintaining real apps, shipping features under pressure, and fixing UI bugs that only appear on one weird device, you start discovering widgets that quietly solve problems before they become bugs.</p><p>Today, let’s talk about four underrated Flutter widgets that don’t get enough attention.</p><h4>OverflowBar — Stop Overflows.</h4><p>Ever designed a dialog or bottom sheet with multiple actions…</p><p>…and then watched it <strong>break on smaller screens</strong>?</p><p>Buttons overflow.<br> Text wraps awkwardly.<br> You add Wrap, tweak spacing, and pray.</p><p>That’s exactly why <strong>OverflowBar exists</strong>.</p><pre>OverflowBar(<br>  spacing: 12,<br>  overflowSpacing: 8,<br>  alignment: MainAxisAlignment.end,<br>  children: [<br>    TextButton(onPressed: () {}, child: const Text(&#39;Cancel&#39;)),<br>    ElevatedButton(onPressed: () {}, child: const Text(&#39;Save&#39;)),<br>  ],<br>)</pre><h4>GridPaper — Visual Layout Debugging.</h4><p><strong>If you’ve ever used design or video-editing software</strong>, you’ve probably turned on the grid to check whether elements are aligned, evenly spaced, and visually balanced. <strong>GridPaper works the same way in Flutter.</strong> It overlays a grid on your UI so you can instantly see spacing, alignment, and layout rhythm—without adding borders, colors, or guesswork. Instead of eyeballing pixels, you start thinking in <strong>systems and consistency</strong>, which is exactly how polished UIs are built.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F2ZNSUKb236l_HdORu7kzQ.png" /></figure><pre>class DebugGridWrapper extends StatelessWidget {<br>  final Widget child;<br><br>  const DebugGridWrapper({super.key, required this.child});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    if (kDebugMode) {<br>      return GridPaper(<br>        color: Colors.red,<br>        divisions: 2,<br>        subdivisions: 4,<br>        child: child,<br>      );<br>    }<br>    return child;<br>  }<br>}</pre><p>In <strong>debug mode</strong>, this wrapper shows the GridPaper overlay so you can inspect spacing and alignment while building. In <strong>release mode</strong>, it quietly disappears, keeping your production UI clean. I use this wrapper specifically to avoid shipping debug tools to users — <strong>because yes, I’ve shipped grid overlays to production before… and no, users were not impressed.</strong> Don’t be me.</p><h4>TickerMode — Pause Hidden Animations.</h4><p>Animations are great — until they keep running <strong>when no one can see them</strong>. TickerMode lets you pause all animations below it in the widget tree when a screen is inactive. This is especially useful for tabs, offstage pages, or background screens. Instead of manually managing animation controllers, TickerMode does the right thing automatically—saving battery, CPU, and your future self from performance bugs that only appear in production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gt395e74g2okWVuRHv9uzw.gif" /></figure><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>  runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return const MaterialApp(<br>      debugShowCheckedModeBanner: false,<br>      home: TickerModeSwitchExample(),<br>    );<br>  }<br>}<br><br>class TickerModeSwitchExample extends StatefulWidget {<br>  const TickerModeSwitchExample({super.key});<br><br>  @override<br>  State&lt;TickerModeSwitchExample&gt; createState() =&gt;<br>      _TickerModeSwitchExampleState();<br>}<br><br>class _TickerModeSwitchExampleState extends State&lt;TickerModeSwitchExample&gt; {<br>  bool _animationsEnabled = true;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: const Text(&#39;TickerMode (Correct Usage)&#39;)),<br>      body: Column(<br>        children: [<br>          SwitchListTile(<br>            title: const Text(&#39;Enable animations&#39;),<br>            subtitle: const Text(&#39;Controls TickerMode&#39;),<br>            value: _animationsEnabled,<br>            onChanged: (value) {<br>              setState(() =&gt; _animationsEnabled = value);<br>            },<br>          ),<br>          const Divider(),<br>          Expanded(<br>            child: Center(<br>              child: TickerMode(<br>                enabled: _animationsEnabled,<br>                child: const RotatingIcon(),<br>              ),<br>            ),<br>          ),<br>        ],<br>      ),<br>    );<br>  }<br>}<br><br>class RotatingIcon extends StatefulWidget {<br>  const RotatingIcon({super.key});<br><br>  @override<br>  State&lt;RotatingIcon&gt; createState() =&gt; _RotatingIconState();<br>}<br><br>class _RotatingIconState extends State&lt;RotatingIcon&gt;<br>    with SingleTickerProviderStateMixin {<br>  late final AnimationController _controller;<br><br>  @override<br>  void initState() {<br>    super.initState();<br>    _controller = AnimationController(<br>      vsync: this,<br>      duration: const Duration(seconds: 2),<br>    )..repeat();<br>  }<br><br>  @override<br>  void dispose() {<br>    _controller.dispose();<br>    super.dispose();<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return RotationTransition(<br>      turns: _controller,<br>      child: const Icon(Icons.sync, size: 80),<br>    );<br>  }<br>}</pre><p><strong>Note:</strong></p><p>When I first used TickerMode, I wrapped my animated widget and toggled the enabled flag—but the animation didn’t stop. After some debugging, I learned the catch: TickerMode only affects <strong>animation controllers created inside its widget tree</strong>. In the example, the RotationTransition’s controller lives inside the widget under TickerMode, so toggling the flag pauses and resumes the animation correctly. If the controller were outside, it would keep running—proving that placement in the widget tree is crucial for proper control.</p><ul><li><a href="https://medium.com/@ravi-pai/all-about-gradle-part-1-gradle-basics-every-flutter-dev-must-know-9c1796c77b1d">Gradle Made Simple (Part 1): Gradle Basics Every Flutter Dev Must Know</a></li><li><a href="https://medium.com/@ravi-pai/gradle-made-simple-part-2-gradle-basics-every-flutter-dev-must-know-1bac6cefa977">Gradle Made Simple(Part 2): Gradle Basics Every Flutter Dev Must Know.</a></li><li><a href="https://medium.com/@ravi-pai/gradle-made-simple-part-3-signing-releasing-your-flutter-app-d6af2d1dcd33">Gradle Made Simple (Part 3): Signing &amp; Releasing Your Flutter App.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a971c6b13e37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hidden Flutter Widgets That Make Your App Feel Senior-Level Polished]]></title>
            <link>https://medium.com/@ravi-pai/hidden-flutter-widgets-that-make-your-app-feel-senior-level-polished-f400c013d07a?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f400c013d07a</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 07:32:42 GMT</pubDate>
            <atom:updated>2025-12-29T07:32:42.946Z</atom:updated>
            <content:encoded><![CDATA[<p>Flutter has <em>a lot</em> of widgets.<br>Some are flashy (Hero, AnimatedContainer).<br>Some are famous (ListView, Stack).<br> And then there are the <strong>silent heroes</strong> — widgets that sit in the corner, judging you, waiting for the day you finally need them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rk9EQHMgkw3rkS0SV9C9Qw.png" /></figure><p>Today, let’s talk about four such underrated gems:</p><ul><li>Baseline</li><li>Offstage</li><li>DecoratedBox</li><li>PhysicalModel</li></ul><p>These widgets don’t scream for attention — but when you need them, <strong>nothing else will do</strong>.</p><h4>1.Baseline — Because Text Has Feelings Too.</h4><p>Ever tried to align numbers, text, or symbols in a row and felt like something was just… <em>off</em>? That’s because text has feelings too — it aligns on an invisible line called the <strong>baseline</strong>. The Baseline widget lets you line up text (or even icons) perfectly, no more guesswork with padding or hacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybjvpOaQknhsXrkAoeOA2g.png" /></figure><pre>Column(<br>  mainAxisAlignment: MainAxisAlignment.center,<br>  crossAxisAlignment: CrossAxisAlignment.center,<br>  children: [<br>    Text(&quot;With Padding&quot;),<br>    Row(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      children: [<br>        Text(<br>          &#39;x&#39;,<br>          style: TextStyle(fontSize: 28),<br>        ),<br>        Padding(<br>          padding: const EdgeInsets.only(bottom: 12),<br>          child: Text(<br>            &#39;2&#39;,<br>            style: TextStyle(fontSize: 14),<br>          ),<br>        ),<br>      ],<br>    ),<br><br>    SizedBox(height: 20), <br>    Text(&quot;With Baseline&quot;),<br>    Row(<br>      mainAxisAlignment: MainAxisAlignment.center,<br>      children: [<br>        Text(<br>          &#39;x&#39;,<br>          style: TextStyle(fontSize: 28),<br>        ),<br>        Baseline(<br>          baseline: 12, <br>          baselineType: TextBaseline.alphabetic,<br>          child: Text(<br>            &#39;3&#39;,<br>            style: TextStyle(fontSize: 14),<br>          ),<br>        ),<br>      ],<br>    ),<br>  ],<br>)</pre><p>No padding hacks.<br>No magic numbers stacked on magic numbers.<br>Just baseline doing baseline things.</p><h4>2 Offstage — The Widget That Exists… But Doesn’t.</h4><p>Offstage is like that intern who’s technically on payroll but not visible in meetings.</p><p>It <strong>builds the widget</strong>, keeps its state — <br>but <strong>doesn’t paint it or take space</strong>.</p><p>Using if (State Gets Destroyed)</p><pre>if (showLoader)<br>  CircularProgressIndicator();</pre><p>Using Offstage</p><pre>Offstage(<br>  offstage: !showLoader,<br>  child: CircularProgressIndicator(),<br>)</pre><p>Offstage is sneaky-good because it keeps the widget alive in the widget tree without taking up any layout space or repainting unnecessarily. This makes it perfect for preloaded screens, animations waiting for their moment, or forms you don’t want to reset accidentally. Think of it as a widget that says: <em>“Stay ready, but stay hidden.”</em></p><h3>3 DecoratedBox — When You Don’t Need a Container.</h3><p>Be honest.<br>You’ve written this <strong>way too many times</strong>:</p><pre>Container(<br>  decoration: BoxDecoration(<br>    color: Colors.blue,<br>    borderRadius: BorderRadius.circular(12),<br>  ),<br>)</pre><p>But what if you <strong>only need decoration</strong>?.</p><p>Enter DecoratedBox</p><pre>DecoratedBox(<br>  decoration: BoxDecoration(<br>    color: Colors.blue,<br>    borderRadius: BorderRadius.circular(12),<br>  ),<br>  child: Padding(<br>    padding: const EdgeInsets.all(16),<br>    child: Text(<br>      &#39;I am lighter than Container&#39;,<br>      style: TextStyle(color: Colors.white),<br>    ),<br>  ),<br>)</pre><p>If you don’t need margin, constraints, alignment — <strong>don’t summon the Container god.</strong></p><h4>4. PhysicalModel — Real Shadows, Not Fake Ones.</h4><p>BoxShadow is fine… until it’s not.</p><p>If you want <strong>real elevation</strong>, clipping, and shadows that behave like Material — PhysicalModel is your friend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DJ8FNnn6UB0WCz4AGpcN1g.png" /></figure><pre>Column(<br>  mainAxisAlignment: MainAxisAlignment.center,<br>  crossAxisAlignment: CrossAxisAlignment.center,<br>  children: [<br>    SizedBox(width: double.infinity),<br>    Container(<br>      decoration: BoxDecoration(<br>        color: Colors.white,<br>        boxShadow: [<br>          BoxShadow(<br>            blurRadius: 10,<br>            color: Colors.black26,<br>          ),<br>        ],<br>        borderRadius: BorderRadius.circular(16),<br>      ),<br>      child: Padding(<br>        padding: const EdgeInsets.all(16),<br>        child: Text(&#39;Real shadow. Real power.&#39;),<br>      ),<br>    ),<br>    SizedBox(height: 15),<br>    PhysicalModel(<br>      color: Colors.white,<br>      elevation: 8,<br>      shadowColor: Colors.black,<br>      borderRadius: BorderRadius.circular(16),<br>      child: Padding(<br>        padding: const EdgeInsets.all(16),<br>        child: Text(&#39;Real shadow. Real power.&#39;),<br>      ),<br>    ),<br>  ],<br>)</pre><p>If you need more control over shadows — like customizing spread, blur, or color — BoxShadow inside a DecoratedBox is your go-to. But if you just want a <strong>quick, realistic shadow with proper elevation and clipping</strong>, PhysicalModel gets the job done in seconds.</p><p>If this helped, consider sharing it with a fellow dev. For more such finds, hit follow — and until next time, happy Fluttering.</p><ul><li><a href="https://medium.com/@ravi-pai/your-designer-sees-misalignments-even-nasa-cant-here-are-5-flutter-debugging-hacks-963f7b4682e6">Your Designer Sees Misalignments Even NASA Can’t. Here Are 5 Flutter Debugging Hacks.</a></li><li><a href="https://medium.com/@ravi-pai/5-mixins-that-made-my-flutter-code-10x-cleaner-fc3add29c56a">5 Mixins That Made My Flutter Code 10x Cleaner.</a></li><li><a href="https://medium.com/@ravi-pai/these-5-flutter-tricks-turned-my-messy-code-into-magic-4ce8468fcb1c">These 5 Flutter Tricks Turned My Messy Code into Magic</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f400c013d07a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anchored Overlays in Flutter: The Right Way (Yes, There Is One)]]></title>
            <link>https://medium.com/@ravi-pai/anchored-overlays-in-flutter-the-right-way-yes-there-is-one-900cc0d7f103?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/900cc0d7f103</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 22 Dec 2025 07:32:37 GMT</pubDate>
            <atom:updated>2025-12-22T07:32:37.506Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*etDMO5a79CuNu7Uhk7yF4g.png" /></figure><p>I was trying to build a custom tooltip. Nothing fancy — just a small tooltip that shows above a component, like any normal UI would. It felt like a solved problem. Flutter is mature, overlays exist, so this should be easy. I reached for an OverlayEntry, positioned it above the widget, and moved on with confidence.</p><p>To get the position right, I did what every Flutter developer eventually does: grabbed the widget’s RenderBox, used localToGlobal(), added a small offset, and tweaked a few pixels. I ran the app—and it worked. The tooltip appeared exactly where I wanted it. For a brief moment, I felt unstoppable.</p><pre>final box = context.findRenderObject() as RenderBox;<br>    final offset = box.localToGlobal(Offset.zero);<br><br>    return OverlayEntry(<br>      builder: (_) =&gt; Positioned(<br>        left: offset.dx,<br>        top: offset.dy + box.size.height,<br>        child: _overlayBubble(<br>          color: Colors.redAccent,<br>          text: &#39;overlay 😵\nScroll me&#39;,<br>        ),<br>      ),<br>    );</pre><p>At first glance, the code looked right. OverlayEntry, RenderBox, offsets… it all seemed fine. But reality hit when the component landed on a real screen — not a demo, but a scrolling ListView with other widgets and real user interaction. The moment I scrolled, everything broke. The widget moved, but the tooltip didn’t. It just stayed there, frozen, while the component calmly left… like fake teammates in Battle Royale when the situation changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VXUCNrK_krn6BH5Yxydz0w.gif" /></figure><p>I tried the usual wrong fixes — recalculating positions, adding listeners, tweaking offsets. Sometimes it worked, sometimes it broke in new ways. That’s when it clicked: if you’re constantly recalculating overlay positions, you’re already fighting the framework.</p><p>The real solution had been in Flutter all along: CompositedTransformTarget and CompositedTransformFollower. One widget declares itself followable, the other follows it via a LayerLink. I switched to this approach, scrolled again, and everything just worked. No jitter, no lag, no math. I only wondered why I hadn’t learned this sooner.</p><h4>Meet the Two-Widget Pair That Never Get Decoupled.</h4><p>Meet the dynamic duo of Flutter overlays: CompositedTransformTarget and CompositedTransformFollower. These two are the savers that never get decoupled, no matter the situation. The Target marks a widget as something that can be tracked, and the Follower attaches itself to that target, letting Flutter handle all the movement. They are connected using a LayerLink—think of it as the glue that keeps them perfectly in sync.</p><p>Here’s the first piece: wrapping the widget you want to anchor to.</p><pre>final LayerLink _link = LayerLink();<br><br> CompositedTransformTarget(<br>    link: _link,<br>    child: ElevatedButton(<br>       onPressed: _showCorrect,<br>       child: const Text(&#39;Show overlay&#39;),<br>    ),<br>  )</pre><p>The magic kicks in when you create the overlay:</p><pre>OverlayEntry(<br>  builder: (_) =&gt; Positioned.fill(<br>    child: CompositedTransformFollower(<br>      link: _link,<br>      offset: const Offset(0, -40),<br>      showWhenUnlinked: false,<br>      child: TooltipBubble(),<br>    ),<br>  ),<br>);</pre><p>Instead of calculating positions manually, the Follower attaches to the Target. The offset is relative to the widget, not the screen, so scrolling, layout changes, or any chaos in the UI no longer matter.</p><p>Flutter now keeps both widgets perfectly in sync at the compositing layer. When the target moves, the follower moves. When the layout changes, the overlay updates automatically. No listeners, no recalculations, no pixel guessing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O-QzK5tCP5jw_dg9Jf6F5g.gif" /></figure><h3>When to Use This</h3><p>If you’re building anything that behaves like a tooltip, dropdown, context menu, or floating popup, this should be your default choice. The moment you see localToGlobal() in overlay code, ask yourself if a CompositedTransformFollower would work better.</p><p>Once you use this pattern a few times, it’s hard to go back. Your overlays stay anchored, your code gets simpler, and your UI finally stops acting like it has a mind of its own.</p><p>So next time your overlay floats away, remember — it’s not a bug, it’s a breakup. Stop doing math, let Flutter handle it, and use CompositedTransformTarget and CompositedTransformFollower.</p><p>If this helped, consider sharing it with a fellow dev. For more such finds, hit follow — and until next time, happy Fluttering.</p><ul><li><a href="https://medium.com/@ravi-pai/your-designer-sees-misalignments-even-nasa-cant-here-are-5-flutter-debugging-hacks-963f7b4682e6">Your Designer Sees Misalignments Even NASA Can’t. Here Are 5 Flutter Debugging Hacks.</a></li><li><a href="https://medium.com/@ravi-pai/stop-breaking-your-ui-learn-layoutbuilder-like-a-real-flutter-pro-8a90f15cbf0c">Stop Breaking Your UI: Learn LayoutBuilder Like a Real Flutter Pro</a></li><li><a href="https://medium.com/easy-flutter/flutter-magic-build-your-own-particle-system-and-look-like-a-wizard-b1fa55b75c85">Flutter Magic: Build Your Own Particle System (and look like a wizard)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=900cc0d7f103" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Designer Sees Misalignments Even NASA Can’t. Here Are 5 Flutter Debugging Hacks.]]></title>
            <link>https://medium.com/@ravi-pai/your-designer-sees-misalignments-even-nasa-cant-here-are-5-flutter-debugging-hacks-963f7b4682e6?source=rss-86b7e6ed57f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/963f7b4682e6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Ravi Pai]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 07:32:21 GMT</pubDate>
            <atom:updated>2025-12-15T07:32:21.780Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cRfg6gn7hkFdBHHvVGMBmQ.png" /></figure><p>If you’ve ever worked with a designer, you already know this universal truth:</p><p><strong>Designers don’t have eyes. They have NASA-grade, James-Webb-telescope vision.</strong></p><p>You proudly show them your UI — crispy, clean, <em>perfect</em>.</p><p>And they squint for 0.3 seconds before saying:</p><p><strong>“Umm… that button is 0.75 pixels off-center.”</strong></p><p>Meanwhile, you’re standing there like:</p><p><strong>BRO, WHAT SETTINGS ARE YOU USING?</strong><br>I zoomed to <strong>800%</strong>, inverted the colors, turned on dark mode, sacrificed a coffee mug…<br>I still can’t see anything.</p><p>But okay.</p><p>So here are <strong>5 tricks to debug Flutter UI like a pro</strong>, because the next time your designer calls out alignment issues visible only to eagles and satellites, you’ll actually be ready.</p><h4>1. Use debugPaintSizeEnabled — See Your Layout Skeleton.</h4><p>Sometimes your UI looks fine… until the designer tilts their head 12 degrees and says:</p><blockquote><em>“The padding feels… spiritually incorrect.”</em></blockquote><p>Turn this on and boom: boxes around everything.</p><p><strong>How to enable it:</strong></p><pre>void main() {<br>  debugPaintSizeEnabled = true; // highlight layout boundaries<br>  runApp(MyApp());<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iEgGneAlitZ9OrbqZKscHg.png" /></figure><p>This draws colored outlines, padding boxes, and hit-test areas.<br>Suddenly your margin mistakes become visible.</p><h4><strong>2. Use Flutter Inspector — The MRI Scan of Your UI.</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yV9qUVxeTyKm84eu6SdJ2w.png" /></figure><p>Open DevTools → Inspector → “Select Widget Mode”.<br> Tap on any widget and see:</p><ul><li>Exact constraints</li><li>Padding</li><li>Margins</li><li>Render object</li><li>Parents</li><li>Children</li></ul><p>It’s like performing surgery on your UI.</p><p><strong>Pro tip:</strong> The “Layout Explorer” tab is god-level for Flex debugging.<br>When your Row shrinks your text for no reason, Layout Explorer will show you exactly who&#39;s bullying who.</p><h4>3. Add Temporary Color Blocks — The Caveman Debugging Trick.</h4><p>When you have a layout that just <strong>won’t align</strong>, wrap things in Container</p><pre>Container(<br>  color: Colors.purple.withOpacity(0.2),<br>  child: Text(&quot;UnkownSpace&quot;)<br>)</pre><p>Why it works:</p><ul><li>Visualizes invisible widgets</li><li>Shows why the space is weird</li></ul><p>Designers hate this trick.<br>Developers love it.<br>Humans understand their UI again.</p><h4>4. Use the “Slow Animations” Tool — Catch Misaligned Transitions.</h4><p>Sometimes the designer says <strong><em>That modal slides up 1 pixel too far.</em></strong></p><p>You blink.<br>You see nothing.<br>But okay.</p><p>Turn on <strong>Slow Animations</strong> (DevTools → Flutter Inspector → Clock icon).</p><p>This slows all animations to <strong>5×</strong>, helping you spot:</p><ul><li>Weird bounces</li><li>Misaligned transitions</li><li>Hero animation jumps</li></ul><h4>5.<strong> Use </strong><strong>LayoutBuilder + Logging to Catch Constraint Issues.</strong></h4><p>Whenever your widget behaves differently on devices, it’s usually a <strong>constraint issue</strong>.</p><p>Throw in a quick print to see what the parent is giving you:</p><pre>LayoutBuilder(<br>  builder: (context, constraints) {<br>    print(&quot;MaxWidth: ${constraints.maxWidth}&quot;);<br>    print(&quot;MaxHeight: ${constraints.maxHeight}&quot;);<br>    return child;<br>  },<br>);</pre><p>This reveals:</p><ul><li>Why your Expanded is angry</li><li>Why that container suddenly becomes 0 height</li><li>Why a widget disappears on landscape</li></ul><p>We’ve all been there — squinting at the screen, zoomed in to 500%, nudging a widget by <strong>1px</strong>, questioning our life choices.<br> So share your pain points, your <em>“why is this still misaligned?”</em> moments, and the 1px bugs that stole your peace.</p><ul><li><a href="https://medium.com/@ravi-pai/how-a-tiny-3-kb-json-file-brought-my-flutter-app-to-its-knees-87cb9b8bbb35">How a Tiny 3 KB JSON File Brought My Flutter App to Its Knees</a></li><li><a href="https://medium.com/@ravi-pai/stop-breaking-your-ui-learn-layoutbuilder-like-a-real-flutter-pro-8a90f15cbf0c">Stop Breaking Your UI: Learn LayoutBuilder Like a Real Flutter Pro</a></li><li><a href="https://medium.com/@ravi-pai/its-2025-and-you-re-still-using-a-cable-to-debug-really-03b3840b37e1">It’s 2025 and You’re Still Using a Cable to Debug? Really?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=963f7b4682e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>