<?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 Josteve Adekanbi on Medium]]></title>
        <description><![CDATA[Stories by Josteve Adekanbi on Medium]]></description>
        <link>https://medium.com/@adekanbijosteve?source=rss-3d814f08eef1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*1FDsGmRZ_hrQpaWU</url>
            <title>Stories by Josteve Adekanbi on Medium</title>
            <link>https://medium.com/@adekanbijosteve?source=rss-3d814f08eef1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:04:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adekanbijosteve/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 Animations Made Easy]]></title>
            <link>https://medium.com/@adekanbijosteve/flutter-animations-made-easy-32b2ec2fe4a7?source=rss-3d814f08eef1------2</link>
            <guid isPermaLink="false">https://medium.com/p/32b2ec2fe4a7</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-ui]]></category>
            <category><![CDATA[flutter-animation]]></category>
            <dc:creator><![CDATA[Josteve Adekanbi]]></dc:creator>
            <pubDate>Mon, 24 Feb 2020 01:00:47 GMT</pubDate>
            <atom:updated>2020-02-24T01:00:47.825Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Flutter Image" src="https://cdn-images-1.medium.com/max/318/1*p6GXzT06Nd25lqijdPYzZw.png" /></figure><p>Flutter animations may be very confusing for beginners. As a beginner, you have to know your way around TickerProviderStateMixin, SingleTickerProviderStateMixin, Tweens, AnimationControllers, CurveTweens…</p><p>Or at the intermediate or professional level, nesting multiple transitions may be more stressful and you may have to do it repeatedly😞.</p><p>But rejoice as I present to you a new widget that allows you to write less code and do more animations😁.</p><p>I am a great fan of animations in Flutter and most times I find myself nesting multiple transitions which drove me to create a new Widget that reduces the workload for me…</p><p>Introducing CoupledTransition, say no more to stress</p><h3>Let’s dive in: Implementing a beating heart</h3><p>First, we add the extended_transition dependency in pubsec.yaml</p><pre><strong>dependencies</strong>:<br>  <strong>flutter</strong>:<br>    <strong>sdk</strong>: flutter</pre><pre><em># The following adds the Cupertino Icons font to your application.<br>  # Use with the CupertinoIcons class for iOS style icons.<br>  </em><strong>cupertino_icons</strong>: ^0.1.3<br>  <strong>extended_transitions</strong>: ^0.0.4</pre><p>Next, We import the libraries</p><pre><strong>import &#39;package:extended_transitions/coupled_transition/coupled_transition.dart&#39;</strong>;<br><strong>import &#39;package:extended_transitions/coupled_transition/coupled_transition_controller.dart&#39;</strong>;<br><strong>import &#39;package:extended_transitions/coupled_transition/transition.dart&#39;</strong>;</pre><p>Let’s create a basic page</p><pre><strong>void </strong>main() =&gt; runApp(MyApp());</pre><pre><strong>class </strong>MyApp <strong>extends </strong>StatelessWidget {<br>  <em>// This widget is the root of your application.<br>  </em>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>MaterialApp(<br>      title: <strong>&#39;Flutter Demo&#39;</strong>,<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: HomePage(),<br>    );<br>  }<br>}</pre><pre><strong>class </strong>HomePage <strong>extends </strong>StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>Scaffold(<br>      body: SafeArea(<br>        child: Center(</pre><pre>),<br>      ),<br>    );<br>  }<br>}</pre><p>Now we add the CoupledTransition</p><pre><strong>class </strong>HomePage <strong>extends </strong>StatelessWidget {</pre><pre>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>Scaffold(<br>      body: SafeArea(<br>        child: Center(<br>          child: CoupledTransition(<br>            child: Icon(<br>              Icons.<em>favorite</em>,<br>              color: Colors.<em>red</em>,<br>            ),<br>          ),<br>        ),<br>      ),<br>      floatingActionButton: FloatingActionButton(<br>        onPressed: () {<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>To implement the beating heart, we have to set the scaleAnimation field and which is an object of the Transition class.</p><p>The Transition class has just 3 fields<br>1) Tween: This defines the begin and end values along with how to how to move from the beginning to end through a curve.<br>2) Curve: Defines how smooth the animation will run</p><p><a href="https://api.flutter.dev/flutter/animation/Curves-class.html">Curves class - animation library - Dart API</a></p><p>3)Duration: Defines how long the animation lasts.</p><p>So, setting the scaleAnimation field…</p><pre><strong>class </strong>HomePage <strong>extends </strong>StatelessWidget {</pre><pre>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>Scaffold(<br>      body: SafeArea(<br>        child: Center(<br>          child: CoupledTransition(<br>            child: Icon(<br>              Icons.<em>favorite</em>,<br>              color: Colors.<em>red</em>,<br>            ),<br>            scaleAnimation: Transition(<br>              tween: Tween(begin: 2, end: 2.5),<br>              duration: Duration(milliseconds: 500),<br>            )<br>          ),<br>        ),<br>      ),<br>      floatingActionButton: FloatingActionButton(<br>        onPressed: () {<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>Are we done? No…one last thing, we need a controller (but a very simplified one)</p><p>A controller allows us to tell the animation when to start, reverse, repeat or stop plus everything AnimationController class can do.<br>After declaring the controller, we need a way to tie the controller to the CoupledTransition which brings us to the build field in the CoupledTranstion.<br>The build field is a callback function that takes an object of CoupledTransitionController as a parameter…Enough talk let’s see the code</p><pre><strong>class </strong>HomePage <strong>extends </strong>StatelessWidget {<br>  CoupledTransitionController <strong>controller</strong>;</pre><pre>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>Scaffold(<br>      body: SafeArea(<br>        child: Center(<br>          child: CoupledTransition(<br>            child: Icon(<br>              Icons.<em>favorite</em>,<br>              color: Colors.<em>red</em>,<br>            ),<br>            scaleAnimation: Transition(<br>              tween: Tween(begin: 2, end: 2.5),<br>              duration: Duration(milliseconds: 500),<br>            ),<br>            build: (CoupledTransitionController controller) {<br>              <strong>this</strong>.<strong>controller </strong>= controller;<br>            },<br>          ),<br>        ),<br>      ),<br>      floatingActionButton: FloatingActionButton(<br>        onPressed: () {<br>          <strong>controller</strong>.startAll();<br>          <strong>controller</strong>.repeatAll(reverse: <strong>true</strong>);<br>        },<br>      ),<br>    );<br>  }<br>}</pre><p>Remember the object of CoupledTransitionController we created? all we have to do is assign it to the object from the build callback method. The controller then gives us the ability to start all transitions with the startAll method and even repeat.</p><p>Yes, we are now done implementing a beating heart😁</p><h3>The whole code:</h3><pre><strong>import &#39;package:extended_transitions/coupled_transition/coupled_transition.dart&#39;</strong>;<br><strong>import &#39;package:extended_transitions/coupled_transition/coupled_transition_controller.dart&#39;</strong>;<br><strong>import &#39;package:extended_transitions/coupled_transition/transition.dart&#39;</strong>;<br><strong>import &#39;package:flutter/material.dart&#39;</strong>;</pre><pre><strong>void </strong>main() =&gt; runApp(MyApp());</pre><pre><strong>class </strong>MyApp <strong>extends </strong>StatelessWidget {<br>  <em>// This widget is the root of your application.<br>  </em>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>MaterialApp(<br>      title: <strong>&#39;Flutter Demo&#39;</strong>,<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: HomePage(),<br>    );<br>  }<br>}</pre><pre><strong>class </strong>HomePage <strong>extends </strong>StatelessWidget {<br>  CoupledTransitionController <strong>controller</strong>;</pre><pre>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>Scaffold(<br>      body: SafeArea(<br>        child: Center(<br>          child: CoupledTransition(<br>            child: Icon(<br>              Icons.<em>favorite</em>,<br>              color: Colors.<em>red</em>,<br>            ),<br>            scaleAnimation: Transition(<br>              tween: Tween(begin: 2, end: 2.5),<br>              duration: Duration(seconds: 500),<br>            ),<br>            build: (CoupledTransitionController controller) {<br>              <strong>this</strong>.<strong>controller </strong>= controller;<br>            },<br>          ),<br>        ),<br>      ),<br>      floatingActionButton: FloatingActionButton(<br>        onPressed: () {<br>          <strong>controller</strong>.startAll();<br>          <strong>controller</strong>.repeatAll(reverse: <strong>true</strong>);<br>        },<br>      ),<br>    );<br>  }<br>}</pre><h3>The output:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*mx80HMMiatsJCgxxB94fsA.gif" /></figure><p>I stated earlier that this package supports multiple transitions on its widget. Can we create a beating and blinking heart?…YES😁</p><p>It is as simple as just adding the fadeAnimation</p><pre><strong>void </strong>main() =&gt; runApp(MyApp());</pre><pre><strong>class </strong>MyApp <strong>extends </strong>StatelessWidget {<br>  <em>// This widget is the root of your application.<br>  </em>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>MaterialApp(<br>      title: <strong>&#39;Flutter Demo&#39;</strong>,<br>      theme: ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: HomePage(),<br>    );<br>  }<br>}</pre><pre><strong>class </strong>HomePage <strong>extends </strong>StatelessWidget {<br>  CoupledTransitionController <strong>controller</strong>;</pre><pre>@override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>Scaffold(<br>      body: SafeArea(<br>        child: Center(<br>          child: CoupledTransition(<br>            child: Icon(<br>              Icons.<em>favorite</em>,<br>              color: Colors.<em>red</em>,<br>            ),<br>            scaleAnimation: Transition(<br>              tween: Tween(begin: 2, end: 2.5),<br>              duration: Duration(milliseconds: 500),<br>            ),<br>            fadeAnimation: Transition(<br>              tween: Tween(begin: 0, end: 1),<br>              duration: Duration(milliseconds: 500),<br>              curve: Curves.<em>bounceIn<br>            </em>),<br>            build: (CoupledTransitionController controller) {<br>              <strong>this</strong>.<strong>controller </strong>= controller;<br>            },<br>          ),<br>        ),<br>      ),<br>      floatingActionButton: FloatingActionButton(<br>        onPressed: () {<br>          <strong>controller</strong>.startAll();<br>          <strong>controller</strong>.repeatAll(reverse: <strong>true</strong>);<br>        },<br>      ),<br>    );<br>  }<br>}</pre><h3>Then the output:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-86i2uNMeMvUT-PevIPEcw.gif" /></figure><p>You can see another example at <a href="https://github.com/JosteveGit/coupled_transition_example">https://github.com/JosteveGit/coupled_transition_example</a></p><h3>FAQ</h3><ol><li>Can all transition depend on a single duration and/or curve? YES you should consider setting useCommonController to true and setting a value for commonDuration</li><li>Can I still monitor the controller to know if the animation is done? YES,</li></ol><p>For detailed documentation see:</p><p><a href="https://github.com/JosteveGit/extended_transitions/blob/master/lib/coupled_transition/coupled_transition.dart">https://github.com/JosteveGit/extended_transitions/blob/master/lib/coupled_transition/coupled_transition.dart</a> for detailed documentation</p><h3>This is an open-source project feel free to contribute <a href="https://github.com/JosteveGit/extended_transitions/blob/master/lib/coupled_transition/coupled_transition.dart">https://github.com/JosteveGit/extended_transitions</a>.</h3><h3>Thank You</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32b2ec2fe4a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>