Boost Your Business with Expert Software Solutions : Book a Consultation

Flutter - Animation and motion widgets in Flutter - Easy guide

2 decades experience software company

15+ Years of Experience

Trusted small-scale to enterprise software development company

800+ Projects Completed

Flexible Software Solutions: Your Choice, Your Project

Flexible Engagement Models

Scalable Software Solutions, Personalized to Your Needs: 100% Client Satisfaction Guaranteed

100% client Satisfaction

Flutter is a framework which is specially expertise on different kinds of animations compared to native languages. We can use a lot of animations which are absolutely free out there. This article will show you the best way of how to use flutter animations which are most commonly used.

There are a lot of animations which we can get from “pub.dev”, but flutter SDK also provides some implicit animations built-in. Let’s discuss some of the animations.

Intro Views

This is a dependency that we can create some of the beautiful intro sliders when the app launches for the first time. interviews are specially designed and inspired by Paper Onboarding from scratch.

It has features like easy addition of pages, Circular page reveals, Cool animations, Skip button for skipping app intro and also custom font selection. It does have Material design perfectly.

We need to add dependency to access the features of it

intro_views_flutter: '^2.8.1'

Create a page using Page View model class in this dependency.

Final page = new PageViewModel( pageColor: const Color(0xFF607D8B), iconImageAssetPath: 'assets/taxi-driver.png', iconColor: null, bubbleBackgroundColor: null, body: Text( 'Easy cab booking at your doorstep with cashless payment system', ), title: Text('Cabs'), mainImage: Image.asset( 'assets/taxi.png', height: 285.0, width: 285.0, alignment: Alignment.center, ), titleTextStyle: TextStyle(fontFamily: 'MyFont', color: Colors.white), bodyTextStyle: TextStyle(fontFamily: 'MyFont', color: Colors.white), ); 

You can create a number of Page View Models. It depends on how many screens we need on the intro slider. Add this to IntroViewsFlutter in order to get all the pages listed. You will be seeing listeners and a lot more attributes to style this according to you.

final Widget introViews = new IntroViewsFlutter( [page], onTapDoneButton: (){ //Void Callback }, showSkipButton: true, pageButtonTextStyles: new TextStyle( color: Colors.white, fontSize: 18.0, fontFamily: "Regular", ), ); 

Slider Button

This is used for both iOS and Android and even on the Web. This package provides an easy implementation of a Slider Button. It is a highly customisable iphone alike looking widget.

Add the below dependency in “pubspec.yaml” file to get the all packages used in this animation.

slider_button: ^0.5.0

Add the package below to get access to it.

import 'package:slider_button/slider_button.dart';

Type 1(Circular)

Center(child: SliderButton( action: () { ///Do something here Navigator.of(context).pop(); }, label: Text( "Slide to cancel Event", style: TextStyle( color: Color(0xff4a4a4a), fontWeight: FontWeight.w500, fontSize: 17), ), icon: Text( "x", style: TextStyle( color: Colors.white, fontWeight: FontWeight.w400, fontSize: 44, ), ), 

Type 2(Rectangular)

SliderButton( action: () { ///Do something here OnSlide }, ///Put label over here label: Text( "Slide to cancel !", style: TextStyle( color: Color(0xff4a4a4a), fontWeight: FontWeight.w500, fontSize: 17), ), icon: Center( child: Icon( Icons.power_settings_new, color: Colors.white, size: 40.0, semanticLabel: 'Text to announce in accessibility modes', )), ///Change All the color and size from here. width: 230, radius: 10, buttonColor: Color(0xffd60000), backgroundColor: Color(0xff534bae), highlightedColor: Colors.white, baseColor: Colors.red, ); 

There are some more usages which are used here. You can refer to the “Pub.dev” page to get more information.

Rating Bar

Rating Bars are usually common in every programming language. Coming to flutter, It provides you the immense feeling of different icons to add in the rating bar. It has various attributes in this dependency in order to make the rating bar more stylier according to your usage. A simple but fully customizable rating bar in flutter.

  • We can set minimum and maximum rating
  • Any widgets can be used as a rating or indicator items
  • Supports vertical layout
  • Glows or gives shine on user interaction with the widget
  • Supports RTL model.

Add the below code to get the rating bar in your project.

RatingBar( initialRating: 3, minRating: 1, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, itemPadding: EdgeInsets.symmetric(horizontal: 4.0), itemBuilder: (context, _) => Icon( Icons.star, color: Colors.amber, ), onRatingUpdate: (rating) { print(rating); }, ); 

If you want to use your own icons then use it like this

RatingBar( initialRating: 3, direction: Axis.horizontal, allowHalfRating: true, itemCount: 5, ratingWidget: RatingWidget( full: _image('assets/heart.png'), half: _image('assets/heart_half.png'), empty: _image('assets/heart_border.png'), ), itemPadding: EdgeInsets.symmetric(horizontal: 4.0), onRatingUpdate: (rating) { print(rating); }, ); 

Toggle Switch

Toggle switch is something which we can select and set our desired option. In flutter it is fully customized with desired icons,width,texts,colors,corner radius etc.

For getting started, we need to add the following dependency into our “pubspec.yaml” file under the dependencies.

toggle_switch: "^0.1.4"

Add the following package which comes from dependency to access Toggle Switch features.

import 'package:toggle_switch/toggle_switch.dart';

Usage example:

ToggleSwitch( minWidth: 90.0, cornerRadius: 20, activeBgColor: Colors.green, activeTextColor: Colors.white, inactiveBgColor: Colors.grey, inactiveTextColor: Colors.white, labels: ['YES', 'NO'], icons: [FontAwesomeIcons.check, FontAwesomeIcons.times], onToggle: (index) { print('switched to: $index'); }) 

Simple Animations

These are simple animations where we can create them easily using these features. It supports in all the formats including Web, iOS & Android.

Animated UI example using Flutter
  • Easily we can create custom animations in Stateless widget.
  • Any widgets can be used as a rating or indicator items
  • We can animate Multiple properties at once.
  • Designed with type-safety in mind.
  • Simplified working with AnimationController instances.

Add the following dependency

simple_animations: ^2.2.1

Add the following package

import 'package:simple_animations/simple_animations.dart';

There are three types of animations comes under simple features

1.) Stateless Animations

PlayAnimation( // <-- specify type of animated variable tween: Colors.red.tweenTo(Colors.blue), // <-- define tween of colors builder: (context, child, value) { // <-- builder function return Container( color: value, // <-- use animated value width: 100, height: 100 ); }); 

2.) MultiTween

enum AniProps { width, height, color } // <-- define properties class MyWidget extends StatelessWidget { final _tween = MultiTween() // <-- design tween ..add(AniProps.width, 0.0.tweenTo(400.0), 1000.milliseconds) ..add(AniProps.width, 400.0.tweenTo(300.0), 1000.milliseconds) ..add(AniProps.height, 500.0.tweenTo(200.0), 2000.milliseconds) ..add(AniProps.color, Colors.red.tweenTo(Colors.blue), 2.seconds); @override Widget build(BuildContext context) { return ... // <-- use tween } } 

3.) Anicoto

class _MyAnimatedWidgetState extends State with AnimationMixin { // <-- add AnimationMixin to state class Animation size; // <-- declare animation variable @override void initState() { size = 0.0.tweenTo(200.0).animatedBy(controller); // <-- connect tween and controller and apply to animation variable controller.play(); // <-- start the animation playback super.initState(); } @override Widget build(BuildContext context) { return Container( width: size.value, // <-- use animation variable's value here height: size.value, // <-- use animation variable's value here color: Colors.red ); } } 

Staggered Animations

This is used for making ListView items to display with some animations. We can also perform these animations in GridView, Column and Row.

Add the following dependency inside the “pubspec.yaml”.

dependencies:

flutter_staggered_animations: "^0.1.2"

Add the following package to get all the features present in Staggered Animations.

import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';

Basic Use

Basic usage of Staggered Animations which we can use in the ListView.

@override Widget build(BuildContext context) { return Scaffold( body: AnimationLimiter( child: ListView.builder( itemCount: 100, itemBuilder: (BuildContext context, int index) { return AnimationConfiguration.staggeredList( position: index, duration: const Duration(milliseconds: 375), child: SlideAnimation( verticalOffset: 50.0, child: FadeInAnimation( child: YourListChild(), ), ), ); }, ), ), ); } 

This package contains three types of classes for making staggered animations.

1.) Animation

2.) AnimationConfiguration

3.) AnimationLimiter

We can use different types of animations to make items of list to display accordingly.

  • FadeInAnimation
  • SlideAnimation
  • ScaleAnimation
  • FlipAnimation

Folding Cell

It is a simple folding widget where we can hide our main content and show it when clicked on open. It is available on both iOS & Android and also on the Web.

Add the following dependency into your “pubspec.yaml” file in order to access all the features in it.

dependencies:

folding_cell: "^1.0.0"

Add the following package

import 'package:folding_cell/folding_cell.dart';

Basic Usage

We need to create all the cards to show the information to the user.

v 1.0.0

class FoldingCellSimpleDemo extends StatelessWidget { final _foldingCellKey = GlobalKey(); @override Widget build(BuildContext context) { return Container( color: Color(0xFF2e282a), alignment: Alignment.topCenter, child: SimpleFoldingCell.create( key: _foldingCellKey, frontWidget: _buildFrontWidget(), innerWidget: _buildInnerWidget(), cellSize: Size(MediaQuery.of(context).size.width, 140), padding: EdgeInsets.all(15), animationDuration: Duration(milliseconds: 300), borderRadius: 10, onOpen: () => print('cell opened'), onClose: () => print('cell closed'), ), ); } Widget _buildFrontWidget() { return Container( color: Color(0xFFffcd3c), alignment: Alignment.center, child: Stack( children: [ Align( alignment: Alignment.center, child: Text( "CARD TITLE", style: GoogleFonts.aldrich( color: Color(0xFF2e282a), fontSize: 20.0, fontWeight: FontWeight.bold, ), ), ), Positioned( right: 5, bottom: 0, child: FlatButton( onPressed: () => _foldingCellKey?.currentState?.toggleFold(), child: Text( "OPEN", ), textColor: Colors.white, color: Colors.indigoAccent, splashColor: Colors.white.withOpacity(0.5), ), ) ], ), ); } Widget _buildInnerWidget() { return Container( color: Color(0xFFecf2f9), padding: EdgeInsets.only(top: 10), child: Stack( children: [ Align( alignment: Alignment.topCenter, child: Text( "CARD TITLE", style: GoogleFonts.aldrich( color: Color(0xFF2e282a), fontSize: 22.0, fontWeight: FontWeight.bold, ), ), ), Align( alignment: Alignment.center, child: Text( "CARD DETAIL", style: GoogleFonts.aldrich( color: Color(0xFF2e282a), fontSize: 40.0, ), ), ), Positioned( right: 5, bottom: 0, child: FlatButton( onPressed: () => _foldingCellKey?.currentState?.toggleFold(), child: Text( "Close", ), textColor: Colors.white, color: Colors.indigoAccent, splashColor: Colors.white.withOpacity(0.5), ), ), ], ), ); } } 

v 0.1.2

class FoldingCellSimpleDemo extends StatelessWidget { final _foldingCellKey = GlobalKey(); @override Widget build(BuildContext context) { return Container( color: Color(0xFF2e282a), alignment: Alignment.topCenter, child: SimpleFoldingCell( key: _foldingCellKey, frontWidget: _buildFrontWidget(), innerTopWidget: _buildInnerTopWidget(), innerBottomWidget: _buildInnerBottomWidget(), cellSize: Size(MediaQuery.of(context).size.width, 125), padding: EdgeInsets.all(15), animationDuration: Duration(milliseconds: 300), borderRadius: 10, onOpen: () => print('cell opened'), onClose: () => print('cell closed')), ); } Widget _buildFrontWidget() { return Container( color: Color(0xFFffcd3c), alignment: Alignment.center, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("CARD", style: TextStyle( color: Color(0xFF2e282a), fontFamily: 'OpenSans', fontSize: 20.0, fontWeight: FontWeight.w800)), FlatButton( onPressed: () => _foldingCellKey?.currentState?.toggleFold(), child: Text( "Open", ), textColor: Colors.white, color: Colors.indigoAccent, splashColor: Colors.white.withOpacity(0.5), ) ], )); } Widget _buildInnerTopWidget() { return Container( color: Color(0xFFff9234), alignment: Alignment.center, child: Text("TITLE", style: TextStyle( color: Color(0xFF2e282a), fontFamily: 'OpenSans', fontSize: 20.0, fontWeight: FontWeight.w800))); } Widget _buildInnerBottomWidget() { return Container( color: Color(0xFFecf2f9), alignment: Alignment.bottomCenter, child: Padding( padding: EdgeInsets.only(bottom: 10), child: FlatButton( onPressed: () => _foldingCellKey?.currentState?.toggleFold(), child: Text( "Close", ), textColor: Colors.white, color: Colors.indigoAccent, splashColor: Colors.white.withOpacity(0.5), ), ), ); } } 

Voice Of Customers

Understand what drives customer satisfaction and loyalty through their genuine feedback and insights.

Happy Client Recommends Top Phoenix App DevelopersPhoenix Mobile App Development Company Client Testimonial

We've been working with Amar Infotech since 2014 on our project, Lyrics Guru. Their team provided top-notch Flutter Mobile App development along with a Laravel admin panel, perfectly meeting our needs.

Over the years, their consistent support and expertise have been invaluable to us.

We highly recommend Amar Infotech for their exceptional service and dedication to client success.

Happy Customer Recommends Top Sri Lanka Travel and Tour CMS Website Development CompanySatisfied Customer Reviews Best Travel and Tour CMS Websites in Sri Lanka

Hi, I'm Philipp Müller, CEO of a Tour and Travel Agency in Sri Lanka. We chose Amar Infotech to bring our website to life with their Tour Package Extranet Services.

hey delivered excellent service, developing a Laravel-based backend that allows us to create and customize our own tour packages easily.

I highly recommend Amar Infotech for their professionalism and expertise in web development.

Client Testimonial - Best Travel App in the USA - Goeasyaviation and GoeasyticketPositive Feedback on Goeasyaviation and Goeasyticket Air Shipping, Flight, and Hotel Booking

Hello, my name is Tito. We would like to extend our gratitude to Amar Infotech for their invaluable assistance in developing our website and app.

They were extremely helpful throughout the entire journey, guiding us every step of the way. Their professionalism is second to none.

Thanks to them, we now have a fully functional Flight Booking website that perfectly meets our needs.

Professional Travel Website Development: Amar Infotech - Sammy Tours Positive ReviewTop-Rated Travel Website Agency: Sammy Tours Client Testimonial for Amar Infotech

I am the owner of Sammy Tours Sri Lanka, and I am thrilled with Amar Infotech for designing and developing my travel and tourism website.

They created a custom website that perfectly showcases our tour packages for Sri Lanka. Their expertise and dedication have significantly impacted our business.

I highly recommend Amar Infotech for their exceptional service and commitment to excellence.

Why Amar Infotech ?

Flexible IT Solutions Provider

On-demand, Flexible

Select the ideal remote team tailored to your business needs.

Affordable IT Services

Cost Benefit

Enjoy up to 30% savings with our competitive solutions.

Experienced IT Consulting Team

Experts Talent

Leverage the expertise of over 100 skilled IT professionals.

Compliance and Security Standards

Risk Free Delivery

Ensure success with agile project management and consistent, reliable outcomes.

Why Choose Amar InfoTech - Trusted IT Partner

Innovative Solutions

Benefit from cutting-edge technology and creative approaches that drive your business forward.

Amar InfoTech - IT Services Brochure for Download

Download Our Brochure for Exclusive Insights!

Discover how we drive success with innovative solutions tailored for your needs. Get a comprehensive overview of our expertise and achievements in just one click.

Download Now

Awards & Recognitions

Celebrating our journey of excellence with accolades that inspire us to reach new heights.

Amar Infotech Top Software Developers - Clutch
Top Software Development Company Amar Infotech - Goodfirms
Amar Infotech Best Company to Work with - GoofFirms
Top 10 Custom Software Development Company - Amar Infotech
Amar Infotech Top Rated Software Development Company
Top Web Development Company - Amar Infotech

Global Presence & Representative

Expanding horizons with a global network of representatives dedicated to delivering excellence across borders.

Amar Infotech Web Development Office in India

India (HQ)

4th Floor, Sunrise Avenue, Stadium - Commerce Six Road, Ahmedabad, INDIA

sales@amarinfotech.com
Amar Infotech Mobile App Development Office in the USA

USA

AI Jones (Account Executive), Phoenix, AZ 85013, 1.623.205.2415

ajones@amarinfotech.com
Amar Infotech Software Consulting Office in Canada

Canada

Ronak Patel (Sales Person), 64 caranci crescent Brampton ON Canada

ronak@amarinfotech.com
Amar Infotech Graphic Design and IT Services Office in Australia

Australia

Jessica (Sales Person), 9 nirimba drive quackers hill nsw 2763

jessica@amarinfotech.com
Amar Infotech Digital Solutions Office in the Netherlands

Netherlands

Adam (Sales Person) in Breda, Netherlands

adam@amarinfotech.com