how-to-add-4-stunning-animations-in-flutter

How to Add 4 Stunning Animations in Flutter?

Flutter Animations: Lottie, Rive, Implicit & Explicit Animations

Have you ever used an app that just felt… smooth? The kind of app where buttons respond with a tap, images transition smoothly, or something just feels alive? That’s the magic of animations in Flutter! They make apps not only visually appealing but also easier and more fun to use.

If you’re just starting with Flutter animations, you might be wondering how to bring that same magic to your apps. Well, the good news is, Flutter makes it super simple to add animations. Whether you want a quick, simple fade-in for a button or something more interactive, Flutter’s got the tools to bring motion to your apps in no time.

In this post, I’ll walk you through four animation techniques in Flutter: Lottie, Rive, Implicit Animations, and Explicit Animations. Don’t worry if you’re new to this, I’ll break it all down in simple terms so you can easily get started and make your app come alive with Flutter animations. Ready? 

1. Lottie Animations

Bringing Designer Magic to Flutter

Lottie is an animation library developed by Airbnb that allows you to render complex animations designed in Adobe After Effects, exported as JSON using the Bodymovin plugin. These animations are lightweight, scalable, and can be controlled dynamically in your app.

How to Use Lottie in Flutter

To get started with Lottie, you’ll need to install the lottie package in your pubspec.yaml file:

				
					dependencies:
  lottie: ^3.0.0

				
			

Then, import the lottie package in your Dart file:

				
					import 'package:lottie/lottie.dart';

				
			

Now, you can add your Lottie animation like this:

				
					Lottie.asset('assets/animation.json'),
				
			

Why Use Lottie Animations?

  • Lightweight: The animations are vector-based and export as JSON files, making them lightweight.
  • Easy Collaboration: Lottie simplifies the handoff between designers and developers, as the animations are already created in After Effects.
  • Flexible Control: You can loop, reverse, or pause animations with ease, and integrate them with user interactions.

With Lottie, you can add beautiful, high-quality Flutter animations without the hefty performance cost. It’s perfect for intro animations, splash screens, or loading indicators!

2. Rive Animations

Interactive Animations for the Win

Rive is a powerhouse when it comes to interactive animations. Unlike Lottie, Rive allows for real-time manipulation and state-driven animations using state machines. This makes Rive perfect for apps where you need dynamic, interactive elements.

How to Use Rive in Flutter

To use Rive in Flutter animations, start by adding the rive package to your pubspec.yaml:

Installation:
				
					dependencies:
  rive: ^0.11.0
				
			

Then, import the package and use the RiveAnimation widget to display your animation:

Usage:

				
					import 'package:rive/rive.dart';

RiveAnimation.asset(
  'assets/animation.riv',
  fit: BoxFit.cover,
),

				
			

Why Choose Rive for Interactive Animations?

  • Interactive State Machines: Rive allows you to create animations with complex logic and state-driven transitions.
  • Real-Time Control: You can manipulate the animation in real-time using input triggers. This means you can have animations change when a user taps a button or interacts with a UI element.
  • Versatile: It’s great for buttons, icons, or interactive scenes where the animation is tightly coupled with user actions.

With Rive, you get the best of both worlds: beautiful designs and real-time interactivity. It’s perfect for gaming apps, interactive UI elements, or custom animations that change based on user input.

3. Implicit Animations

Not every Flutter animation needs to be complex! Implicit animations are perfect when you want a simple, automatic animation that happens when a widget’s properties change, like changing a widget’s size, colour, or position.

These Flutter animations don’t require an AnimationController or manual intervention; Flutter handles it for you. Implicit animations are great for minor UI tweaks, such as transitions between screens or hovering effects on buttons.

How to Use Implicit Animations

You can use implicit Flutter animations with built-in Flutter widgets.  

Common Widgets:
  • AnimatedContainer
  • AnimatedOpacity
  • AnimatedAlign
  • AnimatedPositioned
  • AnimatedPadding
Example:
				
					AnimatedContainer(
  duration: Duration(seconds: 1),
  curve: Curves.easeInOut,
  color: _isToggled ? Colors.blue : Colors.red,
  width: _isToggled ? 200 : 100,
  height: _isToggled ? 100 : 200,
)

				
			

Why Use Implicit Animations in Flutter?

  • Super Easy: With just a few lines of code, you can animate common UI changes.
  • Perfect for UI Transitions: Use implicit animations for buttons, containers, or other widgets that need to change their properties smoothly.
  • No Extra Setup: Flutter automatically handles the animations for you, making it quick and easy to implement.

Implicit animations are ideal for subtle UI effects such as buttons changing colour, cards expanding, or content sliding in and out.

4. Explicit Animations

While implicit animations are great for simple transitions, explicit animations offer complete control over the animation process. They’re perfect for creating complex animations or when you need precise timing, sequencing, or multiple animations running at the same time.

Explicit animations offer complete control over the animation process via AnimationController, Tween, and AnimatedBuilder.

Key Components:
  • AnimationController
  • Tween / CurveTween
  • AnimatedBuilder / AnimatedWidget

How to Use Explicit Animations in Flutter

Here’s an example of how to use explicit animations in Flutter Odoo:

Example:
				
					class MyAnimationWidget extends StatefulWidget {
  @override
  _MyAnimationWidgetState createState() => _MyAnimationWidgetState();
}

class _MyAnimationWidgetState extends State<MyAnimationWidget>
    with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  late Animation<double> _animation;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(seconds: 2),
      vsync: this,
    );
    _animation = Tween<double>(begin: 0, end: 300).animate(_controller);
    _controller.repeat(reverse: true);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
      animation: _animation,
      builder: (context, child) {
        return Container(
          width: _animation.value,
          height: _animation.value,
          color: Colors.green,
        );
      },
    );
  }
}

				
			

Why Use Explicit Animations in Flutter?

  • Complete Control: You can animate almost anything and have full control over the animation’s speed, direction, and behaviour.
  • Custom Timing & Sequence: Use explicit animations for complex sequences like delayed animations, multi-step animations, or coordinated movements.
  • Precise Handling: You control the animation flow, start, stop, repeat, reverse, etc.

Explicit animations are a must when you want to create advanced interactions, like custom button animations, carousel sliders, or multi-step animations.

Animations Made Easy with Flutter

Flutter offers a rich set of tools for creating stunning animations, whether you want to animate simple UI transitions or build complex, interactive designs. Here’s a quick recap:

  • Lottie: Best for lightweight, designer-crafted animations.
  • Rive: Ideal for interactive, state-driven animations with real-time control.
  • Implicit Animations: Perfect for simple UI changes with no extra code.
  • Explicit Animations: Full control for advanced, custom animations.

So, whether you’re adding subtle transitions or creating a highly interactive app experience, Flutter has a solution for every animation need. Mastering these tools will not only make your apps look cooler but also keep your users engaged and entertained.

Got a favourite Animations in Flutter trick? Share it in the comments, and let’s chat about it! Or, if you’re just starting, try experimenting with Lottie or Implicit Animations for a smooth and straightforward introduction to the world of Flutter animations.

Picture of Veerabhadram Rudrararpu

Veerabhadram Rudrararpu

I'm Veerabhadram Rudrararpu, a Flutter Developer focused on building high-performance, cross-platform mobile apps with clean code and responsive UI/UX. Passionate about solving real-world problems and delivering user-centric solutions through modern mobile technologies.

Get a free quote