<?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 Abdur Rahman on Medium]]></title>
        <description><![CDATA[Stories by Abdur Rahman on Medium]]></description>
        <link>https://medium.com/@abiabdullahinshaalloh?source=rss-ee388e572e55------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BEmcf5GcdE8iJvvY</url>
            <title>Stories by Abdur Rahman on Medium</title>
            <link>https://medium.com/@abiabdullahinshaalloh?source=rss-ee388e572e55------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:55:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abiabdullahinshaalloh/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[Mastering Flutter Animations: From Basics to Ping-Pong Motion]]></title>
            <link>https://medium.com/@abiabdullahinshaalloh/mastering-flutter-animations-from-basics-to-ping-pong-motion-c240d711c4fc?source=rss-ee388e572e55------2</link>
            <guid isPermaLink="false">https://medium.com/p/c240d711c4fc</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter-ui-design]]></category>
            <category><![CDATA[flutter-animation]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Abdur Rahman]]></dc:creator>
            <pubDate>Thu, 01 Jan 2026 18:19:05 GMT</pubDate>
            <atom:updated>2026-01-01T18:22:30.280Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8D6LYNZZJ_7K6eblKYdYvw.png" /></figure><p>Flutter animations often feel hard, not because they are complex, but because many tutorials teach them as code to copy rather than concepts to understand. We paste an AnimationController, add a Tween, and hope the UI moves the way we want. When it does not, we start guessing.</p><p>This article takes a different path. Instead of focusing on ready-made effects, it explains how Flutter animations work at a fundamental level. By treating animations as values that change over time, the goal is to build intuition so complex motion becomes predictable, debuggable, and easy to design.</p><h3>Understanding Animations as Values</h3><p>The first thing every Flutter developer should understand is that animations are not visual effects. An animation in Flutter is simply a value that changes over time.</p><p>For example, if you want a box to grow from 0 to 100 pixels:</p><pre>AnimationController _controller = AnimationController(<br>  duration: Duration(seconds: 2),<br>  vsync: this,<br>);<br><br>Animation&lt;double&gt; heightAnimation = Tween&lt;double&gt;(begin: 0, end: 100)<br>    .animate(_controller);<br><br>_controller.forward();</pre><ul><li>_controller is the <strong>timeline</strong> (0 → 1).</li><li>Tween maps this progress to actual <strong>UI values</strong> (0 → 100).</li><li>heightAnimation.value gives the current height for the box at any moment.</li></ul><p>The Tween does <strong>not control speed ,</strong>that’s determined by the controller’s duration. The Tween only tells Flutter <strong>how to map the 0–1 progress to real values</strong>.</p><h3>Using SingleTickerProviderStateMixin and vsync</h3><p>Every controller needs a ticker, which is like a metronome ticking every frame, usually 60 times per second. By mixing in SingleTickerProviderStateMixin, you provide one ticker for your controller.</p><pre>class _MyWidgetState extends State&lt;MyWidget&gt; with SingleTickerProviderStateMixin</pre><p>If you have multiple controllers, you would use <strong>MultipleTickerProviderStateMixin</strong>. Without vsync, the animation would tick even when the widget is offscreen, wasting resources and potentially causing memory issues.</p><h3>Optimizing Rebuilds with AnimatedBuilder</h3><p>A common beginner mistake is using addListener with setState, which rebuilds the entire widget tree. Flutter provides AnimatedBuilder to rebuild only the animated widgets.</p><pre>AnimatedBuilder(<br>  animation: _controller,<br>  builder: (context, child) {<br>    return Container(<br>      width: _widthAnimation.value,<br>      height: _heightAnimation.value,<br>      color: _colorAnimation.value,<br>    );<br>  },<br>)</pre><p>The <strong>child </strong>parameter allows you to pass static widgets that do not need to rebuild, making the animation more efficient.</p><h3>Adding Curves for Natural Motion</h3><p>Linear animations often feel robotic because the speed is constant. Flutter provides curves to make animations feel more natural.</p><pre>CurvedAnimation(<br>  parent: _controller,<br>  curve: Curves.easeInOut,<br>)</pre><p>Curves modify the controller’s linear progress to create non-linear motion, giving the animation smooth acceleration and deceleration. You can combine a Tween with a CurvedAnimation to control both the range and the motion style.</p><h3>Multiple Animations with a Single Controller</h3><p>You can drive multiple properties using a single controller. For example, you can animate width, height, and color simultaneously:</p><pre>heightAnimation = Tween&lt;double&gt;(begin: 0, end: 200).animate(_controller);<br>widthAnimation = Tween&lt;double&gt;(begin: 0, end: 200).animate(_controller);<br>colorAnimation = ColorTween(begin: Colors.red, end: Colors.blue).animate(_controller);</pre><ul><li>One controller is enough because all animations share the same ticker.</li><li>This approach is efficient and keeps animations synchronized.</li></ul><h3>AnimationStatus and Ping-Pong Motion</h3><p>Every animation has a status that tells you what the animation is doing at any given moment:</p><pre>enum AnimationStatus {<br>  dismissed, // controller value is 0<br>  forward,   // animation running 0 to 1<br>  reverse,   // animation running 1 to 0<br>  completed, // controller value is 1<br>}</pre><p>You can listen to the status to reverse or loop animations:</p><pre>_controller.addStatusListener((status) {<br>  if (status == AnimationStatus.completed) {<br>    _controller.reverse();<br>  } else if (status == AnimationStatus.dismissed) {<br>    _controller.forward();<br>  }<br>});<br><br>_controller.forward();</pre><p>This produces a smooth ping-pong effect where the animation moves forward, then backward, repeatedly.</p><p>You can also use _controller.repeat(reverse: true) as a shortcut for the same effect.</p><h3>Key Insights</h3><ul><li>Tween defines value mapping, not speed.</li><li>Controller duration determines speed.</li><li>Curves make the motion feel natural.</li><li>Multiple animations can share a single controller.</li><li><em>AnimationStatus</em> allows you to control reversals and loops.</li></ul><p>This structured approach builds a strong foundation for advanced Flutter animations. Once you are comfortable with <em>controllers</em>, <em>Tweens</em>, <em>curves</em>, and <em>status listeners</em>, you can move on to staggered animations, multiple controllers, hero transitions, and interactive complex UI motion.</p><p>This article was written based on my own learning and experiments with Flutter animations. I used an AI writing assistant to refine clarity, structure, and grammar. If you are a developer who writes blogs or documentation and struggles with clarity or grammar, I personally use <a href="https://play.google.com/store/apps/details?id=com.waysol.prowriteai"><strong>ProWrite AI</strong></a> to polish drafts and improve readability without changing technical intent.<br>You can check it out here: <a href="https://play.google.com/store/apps/details?id=com.waysol.prowriteai">ProWrite AI</a></p><p>I have pushed all the animation examples and class-wise source code used in this article to GitHub.<br>Repository link: <a href="https://github.com/abdurrahmanador/flutter_animations">https://github.com/abdurrahmanador/flutter_animations</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c240d711c4fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>