<?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 sidney_pao on Medium]]></title>
        <description><![CDATA[Stories by sidney_pao on Medium]]></description>
        <link>https://medium.com/@sidney_pao?source=rss-1e463b38262e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ebdS6m3C-1Wig_ysxV1ygQ.jpeg</url>
            <title>Stories by sidney_pao on Medium</title>
            <link>https://medium.com/@sidney_pao?source=rss-1e463b38262e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 15:13:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sidney_pao/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[Mouse Cursor Trail Effect With Flutter]]></title>
            <link>https://medium.com/@sidney_pao/mouse-cursor-trail-effect-with-flutter-a342b6ec06f6?source=rss-1e463b38262e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a342b6ec06f6</guid>
            <category><![CDATA[cursor-trail]]></category>
            <category><![CDATA[flutter-animation]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[sidney_pao]]></dc:creator>
            <pubDate>Thu, 07 Sep 2023 21:22:26 GMT</pubDate>
            <atom:updated>2023-11-08T21:56:07.525Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="title: Mouse cursor trail effect with Flutter" src="https://cdn-images-1.medium.com/max/1024/1*Wkrzm5md7EoE2JpZ2t9jxA.png" /></figure><p>Hello World!</p><p>If you ask me for one of the UI effects that I enjoy the most I’d have to say the mouse trailing effect. <br>It looks like a tail of the mouse cursor as it moves around the screen. Somehow like when you see a comet in the sky.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/1*kkxr6HqUcuJ4RtY7hzx81g.png" /></figure><p>Today we will learn how to create this effect with Flutter.</p><blockquote>PS: If you were thinking that this works with animations, you are totally right. We’ll use some built-in Flutter animated widgets</blockquote><h3>Cursor Trail Main Idea</h3><p>For our cursor trail, imagine that we have a paper sheet (our canvas) that the mouse cursor is our pencil, and that the trail is the trace we paint with our pencil .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/1*RKnPgLucPpdj-WDl27b1RQ.png" /></figure><p>With this in mind, let’s begin:</p><h3>Implementation</h3><p>On your Flutter project, add a new dart file called cursor_animated_trail.dart . Here we will add all the logic and clases to bring that trail to reality.</p><ul><li>first, let’s create a class to handle the looks of each component in the trail. This will be called AnimatedCursorTrailState , here we will set our widget looks state. decoration, size and offset.</li></ul><p>Eeach element of the trail will be painted in a specific point in the canvas, that would be the Offset. a pair of points <em>x</em> and <em>y</em> [:Offset(<em>dx</em>, <em>dy</em>)] understood as the position of an element in the screen.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:provider/provider.dart&#39;;<br><br>class AnimatedCursorTrailState {<br>  const AnimatedCursorTrailState({<br>    this.decoration = defaultDecoration,<br>    this.offset = Offset.zero,<br>    this.size = defaultSize,<br>  });<br><br>  static const Size defaultSize = Size(20, 20);<br>  static const BoxDecoration defaultDecoration = BoxDecoration(<br>    color: Colors.pink,<br>  );<br><br>  final BoxDecoration decoration;<br>  final Offset offset;<br>  final Size size;<br>}</pre><blockquote>Note: Until here, I haven’t said what the widget is specificly, just how it might look like, not what it looks like yet.</blockquote><p>Now, we’ll add a <em>AnimatedCursorTrailProvider</em> class on which we will handle the behavior of our cursor in order to paint the trail. This class extends from <em>ChangeNotifier</em> as we need other to be notified of that behavior so they can react accordingly.</p><pre> class AnimatedCursorTrailProvider extends ChangeNotifier {<br>  AnimatedCursorTrailProvider();<br><br>  AnimatedCursorTrailState state = AnimatedCursorTrailState();<br><br>  void updateCursorPosition(Offset position) {<br>    state = AnimatedCursorTrailState(offset: position);<br>    notifyListeners();<br>  }<br>}</pre><ul><li>In this class, first, we create an instance of <em>AnimatedCursorTrailState.</em></li><li>then we have one method<strong>updateCursorPosition()</strong>that will update the position of our trail.</li></ul><h4>Trail</h4><p>Now let’s create the trail itself.</p><pre>class AnimatedCursorTrail extends StatelessWidget {<br>  const AnimatedCursorTrail({<br>    super.key,<br>    this.child,<br>  });<br><br>  final Widget? child;<br><br>  void _onCursorUpdate(BuildContext context, PointerEvent event) =&gt;<br>      context.read&lt;AnimatedCursorTrailProvider&gt;().updateCursorPosition(<br>            event.position,<br>          );<br><br>  List&lt;Widget&gt; _trail(AnimatedCursorTrailProvider provider) {<br>    final result = &lt;Widget&gt;[];<br><br>    for (var index = 0; index &lt; provider.listTrail.length; index++) {<br>      if (index % 10 == 1) {<br>        result.add(provider.listTrail.elementAt(index));<br>      }<br>    }<br><br>    return result;<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return ChangeNotifierProvider(<br>      create: (context) =&gt; c(),<br>      child: Consumer&lt;AnimatedCursorTrailProvider&gt;(<br>        builder: (context, provider, child) {<br>          final state = provider.state;<br><br>          return Stack(<br>            children: [<br>              if (child != null) child,<br>              Positioned.fill(<br>                child: MouseRegion(<br>                  onHover: (event) {<br>                    _onCursorUpdate(context, event);<br>                    provider.listTrail.add(<br>                      AnimatedTrail(offset: event.position),<br>                    );<br>                  },<br>                  opaque: false,<br>                ),<br>              ),<br>              AnimatedPositioned(<br>                left: state.offset.dx - state.size.width / 2,<br>                top: state.offset.dy - state.size.height / 2,<br>                width: state.size.width,<br>                height: state.size.height,<br>                duration: Duration(milliseconds: 50),<br>                child: IgnorePointer(<br>                  child: Icon(<br>                      Icons.star,<br>                      color: state.decoration.color,<br>                      size: state.size.height,<br>                  ),<br>                ),<br>              ),<br>            ],<br>          );<br>        },<br>        child: child,<br>      ),<br>    );<br>  }<br>}</pre><p>So, we have the AnimatedCursorTrail stateless widget that receives a child as a parameter, this is because this widget will work as a <strong>wrapper of our content </strong>and will paint the trail where we want it.</p><p>in the build method, we have a ChangeNotifierProvider widget whose child is a Consumer of AnimatedCursorTrailProvider . This means that ChangeNotifierProvider will be able to listen when the state changes in AnimatedCursorTrailProvider, exposing this changes to its descendants.</p><p>The Consumer child will get the Provider from its parent and will pass it to the builder so it can take the changes and animate the trail.</p><p>in the builder we return a Stack widget whose deepest element will be child , then we have a MouseRegion widget that will capture the mouse movement event and a our trail.</p><p>The actual trail component is this piece here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*4HoZHen2zvrnTXKg46fJVA.png" /></figure><p>As you noticed, this trail is an AnimatedPositioned that takes the offset of our pointer (captured in the Consumer builder method) and moves our trail widget towards the pointer, that’s why its a trail, ain’t it?</p><p>This AnimatedPositioned is wrapping an IgnorePointer widget so our clicking events are not interfered. There is some star icon there, probably how the trail will look like.</p><p>In order to see the result on the screen of what we just did, let’s use the wrapper we mention before, Just wrap your widget with AnimatedCursorTrail, and Voilá!</p><p>In my case, the project I have is this <a href="https://codelabs.developers.google.com/codelabs/flutter-codelab-first?hl=en&amp;authuser=2#6">Namer app</a> from one of <a href="https://codelabs.developers.google.com/?product=flutter">Google Flutter Codelabs</a>. I wrapped the GeneratorPage with AnimatedCursorTrail , passed the page content as the child and this is the result:</p><pre>Widget build(BuildContext context) {<br><br>   return AnimatedCursorTrail(<br>      child: Scaffold(<br>           //Page content...<br>       ),<br>    );<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*h8mQq_D3lbad5a74I0xvgQ.gif" /></figure><p>Oops! this doesn’t look like a trail at all! It looks like our star icon feels lonely so it just follows the pointer, and that’s it 😅</p><p>Well, for the trail we can think of it as a repetition of a widget. Each widget will be painted in a specific point in the canvas, right? <br>but if “Trail ::= a repetition of a widget”, how can we multiply a widget?</p><p>Simple! We add the same widget multiple times to some List and paint every element on the list. So, With this in mind let’s modify a little bit our implementation:</p><p>First, Let’s move our tail widget out to a new class:</p><pre>class AnimatedTrail extends StatelessWidget {<br>  const AnimatedTrail({<br>    super.key,<br>    required this.offset,<br>  });<br><br>  final Offset offset;<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Positioned(<br>      left: widget.offset.dx,<br>      top: widget.offset.dy,<br>      child: IgnorePointer(<br>        child: Icon(<br>          Icons.star,<br>          color: AnimatedCursorTrailState.defaultDecoration.color,<br>          size: AnimatedCursorTrailState.defaultSize.height,<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>As you see, We no longer have an AnimatedPositioned widget, since this trail individual widget will be at a specific point in the screen, right?</p><h4>List strategy to build Trail</h4><p>Let’s say that inside our AnimatedCursorTrail widget, we create an empty list in which we will add the trail components as the cursor moves, like this:</p><pre>class AnimatedCursorTrail extends StatelessWidget {<br>  ...<br>  <br>  final trail = &lt;Widget&gt;[]; // Here <br><br>  @override<br>  Widget build(BuildContext context) {<br>    return ChangeNotifierProvider(<br>      ...<br><br>          return Stack(<br>            children: [<br>              if (child != null) child,<br>              Positioned.fill(<br>                child: MouseRegion(<br>                  onHover: (event) {<br>                    trail.add(                 // From here<br>                      AnimatedTrail(           // Add element to trail<br>                        offset: event.position,   <br>                      ),<br>                    );                         // To here<br>                    _onCursorUpdate(context, event);<br>                  },<br>                  opaque: false,<br>                ),<br>              ),<br>              for (var star in trail) star, // Trail here<br>            ],<br>          );<br>        },<br>        child: widget.child,<br>      ),<br>    );<br>  }<br>}</pre><p>In the onHover(event) method, as the cursor moves we add a star icon element to create the trail, and paint the actual trail using a for loop. <br>Notice that we can see the changes without having a StatefulWidget? <br>That is because the method _onCursorUpdate() results in a notification to the AnimatedCursorTrailProvider subscribers.</p><p>If you reload and check, you’ll see that now we can draw a cursor trail 🥳 (although each point stays in the screen 🤨) something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aj_EJXoauDmA3bpiwrOG6Q.png" /></figure><p>Humk, we don’t need a doodle board, 🤔 that&#39;s a different project! <br>(although, if that’s what you wanted, you got it already and can stop here 🤗)</p><p>For those looking for a Trail, we want each point to desapear nicely after some time. Ok! let&#39;s wrap our star icon with an AnimatedOpacity widget, since this will make that point fade out and avoids that it lingers in the screen. Now,</p><ul><li>Since this animated widget requires some updates in its state, we convert AnimatedTrail to a StatefulWidget.</li><li>create a double value called opacityLevel initialized in 1.0, so the icon is fully visible once it’s created</li><li>create a method changeOpacity() to assing 0.0 to opacityLevel so it becomes ‘invisible’</li><li>inside the build method, call WidgetsBinding.instance.addPostFrameCallback in order to start animation right after the element is built.</li></ul><p>You’ll get something like this:</p><pre>class AnimatedTrail extends StatefulWidget {<br>  ...<br><br>  double opacityLevel = 1.0;<br><br>  void changeOpacity() {<br>    if (mounted) setState(() =&gt; opacityLevel = 0.0);<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    WidgetsBinding.instance.addPostFrameCallback((_) {<br>      changeOpacity();<br>    });<br><br>    return Positioned(<br>      left: widget.offset.dx - 250,<br>      top: widget.offset.dy,<br>      child: IgnorePointer(<br>        child: AnimatedOpacity(<br>          duration: const Duration(seconds: 3),<br>          curve: Curves.ease,<br>          opacity: opacityLevel,<br>          child: const Icon(<br>            Icons.favorite,<br>            color: AnimatedCursorTrailState.defaultDecoration.color,<br>            size: AnimatedCursorTrailState.defaultSize.height,<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Reload and Voilá:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ctJPLMpSk9BrHF78Fxt1aA.gif" /></figure><p>Side Note: When you set the opacity of a widget to 0.0 it is not longer painted in the screen.</p><p>To organize our code better, let’s move the list (trail) to a place where it seems to belong and make things easier for us:</p><pre>class AnimatedCursorTrailProvider extends ChangeNotifier {<br>  AnimatedCursorTrailProvider();<br><br>  AnimatedCursorTrailState state = AnimatedCursorTrailState();<br>  final trail = &lt;Widget&gt;[];<br><br>  void updateCursorPosition(Offset position) {<br>    state = AnimatedCursorTrailState(offset: position);<br>    notifyListeners();<br>  }<br>}</pre><p>If you want, you can have some condition to paint the trail so it doen’t paint a star in every single point but on most of them. This will look smother too!<br>Here, I just add the items to the trail if index <em>mod(30)</em> is 0.</p><p>💫</p><p>Check the full implementation <a href="https://github.com/sidneyaguirre/animations/blob/main/lib/src/widgets/animated_cursor/animated_cursor.dart">here</a></p><h3>Performance considerations</h3><p>This looks amazing when you are running the app locally, but what if you deploy the app containing this effect to some static site hosting service; well, the performance will be an issue since the resources will be very limited for your page.</p><p>Opacity is an expensive task in general (see <a href="https://api.flutter.dev/flutter/widgets/Opacity-class.html#performance-considerations-for-opacity-animation">Performance considerations for opacity animation</a>), since this effect will change opacity to many many elements at the same time, the animation will look janky (non smooth), therefore my approach to use this animation in my site was the following:</p><p>apply good performance practice like making const anything and evrything that doensn’t change, for example: the icon, durations, etc.</p><p>I decided not to use <em>AnimatedOpacity</em>, so I went with <em>AnimatedScale</em> instead. All of this made a huge difference in how the animation looks in <a href="https://sidneyaguirre.github.io/">my site</a>, while still looking cute 🦄</p><p>The end! I hope you enjoyed this 🥹</p><h3>References</h3><ul><li>Cursor Mouse Follow Animation in Flutter -&gt; <a href="https://www.youtube.com/watch?v=CCrmRG-dIfY">https://www.youtube.com/watch?v=CCrmRG-dIfY</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a342b6ec06f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Un Paso a la Vez]]></title>
            <link>https://medium.com/@sidney_pao/mis-decisiones-a-la-ingenieria-de-sistemas-d177beb5ee8f?source=rss-1e463b38262e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d177beb5ee8f</guid>
            <dc:creator><![CDATA[sidney_pao]]></dc:creator>
            <pubDate>Sat, 11 May 2019 20:14:30 GMT</pubDate>
            <atom:updated>2023-09-07T01:20:57.466Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y-fqrw349lRrQRPVy-jT1g.jpeg" /></figure><h3>* Sueños y… ¿Planes?</h3><p>Desde muy pequeña, soñaba con estudiar una carrera profesional, aprender varios idiomas, viajar, entre muchas otras cosas ✨; <strong>era una soñadora constante</strong>, y estando despierta era cómo mejor modelaba mis sueños, al ver la televisión, al jugar, al escuchar a los adultos hablar, siempre añadía detalles a lo que dibujaba mentalmente: <strong>aquello que esperaba lograr algún día</strong>.</p><p>En esa etapa todavía no me correspondía tomar decisiones trascendentales de la vida; apenas sí podía decidir por mí misma si jugaba o no con las niñas de mi barrio 🎀, pero como la vida y el tiempo no se detienen, llegó el momento en que sí debía tomar <strong>decisiones que afectaban profundamente mi vida</strong>; más aún, decisiones que de una u otra forma afectaban también a los que me rodeaban 🌎.</p><p>Estaba en los últimos años del colegio 📚, y <strong>algunos de mis compañeros ya sabían lo que querían para su vida</strong>, y yo seguía soñando; algunos compañeros ya estaban marcando su camino por la vida, algunos pertenecían a agencias de modelaje porque deseaban ser personajes de la televisión (hoy lo son) y <strong>yo seguía soñando</strong>. Pasé por muchas profesiones (en mis sueños, claro), fui músico profesional 🎶, fui escritora 📖, y hasta diseñadora de modas para las futuras estrellas de la tele (y sí, hacía bocetos 🧜‍♀️💃). Pero mi tiempo en el colegio estaba llegando a su fin, y yo ya <strong>no podía seguir solo soñando, debía decidir</strong>.</p><p>Gracias a Dios obtuve buenos resultados en mis pruebas ICFES, y como me gustaban las ciencias, me inscribí a Matemáticas en una excelente universidad en mi ciudad, y pasé 🎉.</p><p>Solo hice un semestre 😣… en ese momento eventos familiares me impidieron continuar con mi educación, y siendo honesta: no veía futuro para mí en esa carrera. Me gustaba, pero quería algo diferente.</p><h3>* Incertidumbre y Preguntas</h3><p><strong>¿Qué me gusta realmente 🤔? ¿qué puedo aprender a hacer y de lo que pueda vivir? ¿Dónde o cómo voy a ganar conocimiento?</strong> Eran solo algunas de las preguntas que reemplazaron mis momentos de ensoñación para dar lugar a la vida real y las decisiones que debián ser tomadas. Profesores y familiares estuvieron dispuestos a orientarme, pero al final era yo quien debía decidir y luego de un tiempo, así lo hice. Ahora tenía que organizar mis ideas, sacar lo mejor de mi banco de sueños, y ver qué podía concretar. Así que ahí estaba: el catálogo de sueños y lo que estaba dispuesta a escoger para mí.</p><p>“No debo decidir todo, solo un paso a la vez”, pensé, así que al caminar la vida, poco a poco, inicié mi viaje hacia mi futuro.</p><h3><strong>* Decisiones</strong></h3><p>0. Decidí estudiar Inglés y perfeccionarlo constantemente.<br>1. Decidí que <strong>dejaría</strong> a mi familia 👨‍👩‍👧, a mis amigos y pueblo natal para vivir y estudiar en otra ciudad.<br>2. Decidí la universidad en la que estudiaría.<br>3. Pero, “¿Qué carrera, qué me gustaba realmente?” seguía sin resolverse. Sin embargo, sin tener muchas nociones sobre lo que realmente quería, y con apenas algunas recomendaciones de familiares y amigos me senté frente al computador para llenar mi formulario de inscripción a la universidad 📄, y ahí estaban: Primera y Segunda opción a las que deseaba aplicar (¡Vaya! si se me hizo difícil escoger solo una opción; dos sería imposible!). Revisé la oferta de carreras de pregrado varias veces, y decidí nuevamente: <br>4. No llenaría el campo de segunda opción, es decir: <strong>pasaba a la U con la primera (y única) opción, ó no pasaba</strong>.<br>5. llené mi formulario con mi primera (y única) opción: <strong>Ingeniería de Sistemas </strong>👩🏻‍💻📑 📊.</p><h3>* Confesiones</h3><p>¿Por qué Ingeniería de Sistemas? si ni se acercaba a las profesiones que soñaba y que intenté desarrollar en el colegio 😲.<br>Por dos razones: <br>Uno, en Ingeniería de Sistemas se usan las matemáticas (y siempre me gustaron las matemáticas), <br>Y Dos, pensé: “no me moriré de hambre si estudio Ingeniería de Sistemas”.</p><p>Ahora, después de realizar lo necesario para mi ingreso a la (¿tan anhelada? 🤔) carrera de Ingeniería, debía esperar la respuesta que podía ser: “admitida” ☑️ ó “no admitida” ❎.</p><p>Bueno… sí, a mi primera opción de inscripción recibí la respuesta 🤩: fuí admitida.</p><h3>* Con-ciencia</h3><p>Nunca quise hacer las cosas por<strong> beneficios meramente materiales</strong>; mi pensamiento acerca de la vida y de mis acciones siempre se han basado en la trascendencia emocional✨ y espiritual que éstas tienen 🙌. Así que no podía estudiar algo que me entregara buena remuneración si me sentía forzada a ejercerlo, eso afectaría mi felicidad en algún punto, de eso era consciente.</p><p>Y entonces, otra decisión debía tomar.</p><p>y… ¿Qué decidí en este punto?</p><p>✨Decidí descubrir la carrera; descubrirla en su profunda y extensa riqueza, asistiendo a clases, leyendo, conociendo los intereses profesionales de mis compañerlos, porque en ello podría encontrar intereses míos también, asistiendo a semilleros, atendiendo eventos en la ciudad sobre temas de tecnología y desarrollo, y fue entonces <strong>en ese punto que me enamoré de la Ingeniería de Sistemas </strong>😍<strong>.</strong></p><p>Me enamoré de cómo puedo ser alguien que interviene y mejora los procesos que rodean a las sociedades, de cómo puedo ser alguien que sin estar presente, brinda ayuda, gracias a las soluciones tecnológicas y lo que llego a hacer en equipo con mis compañeros de trabajo, de vida, de sueños✨, <strong>me enamoré de cómo puedo vivir, trabajar y divertirme en el proceso</strong>.</p><p><em>Credits: Imagen por Designed by rawpixel.com / Freepik</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d177beb5ee8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>