Orchestrate multiple animations with ease.

Overview

flutter_sequence_animation

Features

  • No need to use intervals and calculate percentages for your total animation time.
  • Animate the same variable with multiple animatables!
  • You only need one AnimationController
  • Intuitive and easy to use interface

Installation

dependencies:
  flutter_sequence_animation: "^4.0.0-nullsafety"

then

$ flutter packages get

then

import 'package:flutter_sequence_animation/flutter_sequence_animation.dart';

Demo

alt-text-1 alt-text-1alt-text-1

Code

The Staggered Animation example from here is 207 lines of code . The same animation with this package is 128 lines of code. It is also much easier to read and edit.

You specify a sequence of animatables like this:

    sequenceAnimation = new SequenceAnimationBuilder()
      .addAnimatable(
          animatable: new ColorTween(begin: Colors.red, end: Colors.yellow),
          from:  const Duration(seconds: 0),
          to: const Duration(seconds: 2),
          tag: "color"
        ).addAnimatable(
          animatable: new ColorTween(begin: Colors.yellow, end: Colors.blueAccent),
          from:  const Duration(seconds: 2),
          to: const Duration(seconds: 4),
          tag: "color",
          curve: Curves.easeOut
        ).addAnimatable(
          animatable: new ColorTween(begin: Colors.blueAccent, end: Colors.pink),
          //  animatable: new Tween<double>(begin: 200.0, end: 40.0),
          from:  const Duration(seconds: 5),
          to: const Duration(seconds: 6),
          tag: "color",
          curve: Curves.fastOutSlowIn
        ).animate(controller);

In this case only the color is animated but you can add as many different properties to the sequence as you'd like to. The only restriction is that animations with the same tag can not overlap and need to be ordered.

Now you can access the resulting animation from anywhere in your code with

sequenceAnimation["color"]

This animation is a composition of all animatables you passed in with the same tag.

Example usage of this example:

new AnimatedBuilder(
          builder: (context, child) {
            return new Center(
              child: new Container(
                color: sequenceAnimation["color"].value,
                height: 200.0,
                width: 200.0,
              ),
            );
          },
          animation: controller,
        ),

The animation duration is set automatically (don't change the duration of the controller yourself).

Sepcial thanks to Simon Lightfoot for the help!

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

Comments
  • Null Safety

    Null Safety

    I was trying to use the following flutter_sequence_animation: "^4.0.0-nullsafety"

    however it fails - seems the update is not published.

    Do you plan to publish ?

    opened by Abhijit-Revamp 5
  • General cleanup.

    General cleanup.

    Virtually no arguments in the Flutter framework use abbreviations (like 'anim'). To keep this styling consistent, this pull request changes every instance of 'anim' to 'animatable' to preserve consistency in the Flutter framework.

    Also, I've done some cleanup elsewhere (replaced vars and improved the example code for example).

    It's just a styling choice, really, but I think it makes it more readable and consistent :)

    opened by jeroen-meijer 2
  • New Animatable API. Fixes #4

    New Animatable API. Fixes #4

    Tried the example and updated the dependency for flutter_villains and everything worked ;) (at least for me). As suggested in #4, it is incompatible with flutter versions prior to 0.9.3-pre20 and should probably get a new version like 3.0.0 to avoid issues with people still using an older version of flutter.

    opened by MaximilianKlein 1
  • Broken with Flutter v0.9.3-pre.20 due to new transform abstract method

    Broken with Flutter v0.9.3-pre.20 due to new transform abstract method

    Pull #21540 added the transform(double T) method and made evaluate use this method.

    It's an easy fix, just change the IntervalAnimatable override to transform instead of evaluate, and remove the following line. Not sure how this will affect backward-compatibility though.

    opened by lucaslcode 1
  • Add a LoopMode or something like that

    Add a LoopMode or something like that

    There are a ton of use-cases for having a looping animation.

    My suggestion for the API would be to add a LoopMode to addAnimatable e.g. LoopMode.dontRepeat, LoopMode.pingPong, LoopMode.restart

    Do you think this could be achieved with a reasonable amount of effort? @Norbert515

    opened by modulovalue 1
  • Offset/Delay parameter

    Offset/Delay parameter

    An offset or delay parameter for addAnimatable would be really useful. i.e. if you'd want to delay an animation by a certain duration then providing a delay Duration would remove the need for adding a duration to the from and to values.

    Edit: I also think it would be useful if the SequenceAnimationBuilder had a "global" delay that affected all animatables

    opened by modulovalue 1
  • Controller forward not working

    Controller forward not working

    I always used flutter sequence on init and now I am trying to do it with gesturedetector, but i spend hours trying to figure out why it doesnt work. Could you kindly help? I want the height of the container to grow

    import 'package:flutter/material.dart';
    import 'package:flutter_sequence_animation/flutter_sequence_animation.dart';
    
    // import 'package:speech_bubble/speech_bubble.dart';
    
    class MyProcedureItem extends StatefulWidget {
      final String procedure, pics, description;
      final int index;
      MyProcedureItem(
          {Key key, this.procedure, this.pics, this.description, this.index})
          : super(key: key);
      @override
      _MyProcedureItemState createState() => _MyProcedureItemState();
    }
    
    class _MyProcedureItemState extends State<MyProcedureItem>
        with SingleTickerProviderStateMixin {
      ////////////////////////////////////////
      // Animation code
      AnimationController controller;
      SequenceAnimation sequenceAnimation;
      void initAnimation() {
        controller = AnimationController(vsync: this);
        SequenceAnimationBuilder sab = SequenceAnimationBuilder();
    
        sab.addAnimatable(
          animatable: Tween<double>(begin: 0.0, end: 300.0),
          from: Duration(milliseconds: 0),
          to: Duration(milliseconds: 5000),
          curve: Curves.easeInOutCirc,
          tag: 'question-height',
        );
    
        sequenceAnimation = sab.animate(controller);
      }
    
      @override
      void initState() {
        super.initState();
        initAnimation();
        // _playAnimation();
      }
    
      @override
      void dispose() {
        controller.dispose();
        super.dispose();
      }
    
      Future<Null> _playAnimation() async {
        try {
          await controller.forward().orCancel;
          // await controller.reverse().orCancel;
        } on TickerCanceled {
          // the animation got canceled, probably because we were disposed
        }
      }
    
      @override
      Widget build(BuildContext context) {
        double screenWidth = MediaQuery.of(context).size.width;
        double margin = 20;
        double wholeSize = screenWidth - margin * 2;
        
        
        Widget questions = Container(
          width: wholeSize,
          height:
              sequenceAnimation['question-height'].value ,
          color: Colors.blue,
          margin: EdgeInsets.fromLTRB(0, 0, 0, 20),
        );
        Widget detail = Container(width: 200, height: 200, color: Colors.green);
        return GestureDetector(
            onTap: () {
              _playAnimation();
            },
            child: AnimatedBuilder(
                animation: controller,
                builder: (context, child) => Padding(
                    padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
                    child: Column(children: <Widget>[
                      detail,
                      questions,
                    ])))); 
      }
    }
    
    class Procedure extends StatefulWidget {
      @override
      _ProcedureState createState() => _ProcedureState();
    }
    
    class _ProcedureState extends State<Procedure> {
    
      Widget build(BuildContext context) {
        return Scaffold(
          backgroundColor: Colors.grey[100],
          body: Container(
              // A top margin of 56.0. A left and right margin of 8.0. And a bottom margin of 0.0.
              margin: const EdgeInsets.fromLTRB(0, 10, 0, 10),
              child: new Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisSize: MainAxisSize.max,
                  mainAxisAlignment: MainAxisAlignment.start,
                  // A column widget can have several widgets that are placed in a top down fashion
                  children: [
                    MyProcedureItem(procedure: "blah", description: "foo", index: 0, pics: ""),
                  ]))
        );
      }
    }
    
    
    opened by tmtong 0
  • Type safety

    Type safety

    Hi, thank you very much for your work on this package. It's been my favorite animation add-on since its very first version years ago!

    I've been thinking about a little revamp of the API in order to make it more sound at compile-time. It leverages tags/keys that are generics on the animation type they want to represent, so that it's guaranteed that you can only add animatables (for example tweens) of the given tag type and also extract values of the animatable while using them for the animation at a later time.

    I'll submit this as a draft PR because, if you like the approach, some work needs to be done in order to handle backward compatibility and reword the docs.

    opened by sroddy 0
Owner
Norbert Kozsir
Student, Android Developer, Machine-Learning enthusiast and in love with flutter. Follow me in twitter @ norbertkozsir
Norbert Kozsir
A new Flutter dialog with a series of beautiful animations, slide fade rotate size scale rotate3D animations.

flutter_animated_dialog A new Flutter dialog with a series of beautiful animations, slide fade rotate size scale rotate3D animations. Dialog barrier i

null 20 Dec 3, 2022
Create powerful animations in Flutter and use the hero animation for complex animations

Hero Animation - Locations UI - Flutter Create powerful animations in Flutter and use the hero animation for complex animations. ⚡  Social Media  Twit

null 3 Dec 11, 2021
Page indicator for flutter, with multiple build-in layouts.

flutter_page_indicators Page indicator for flutter, with multiple build-in layouts. NOTE:This project is forked from flutter_page_indicator, because t

OpenFlutter 12 Jun 29, 2022
Page Transition package for multiple navigation types

f_page_transition A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

VAMSI KRISHNA THANIKANTI 1 Oct 29, 2021
🔔 A flutter package to create cool and beautiful text animations. [Flutter Favorite Package]

Animated Text Kit A flutter package which contains a collection of some cool and awesome text animations. Recommended package for text animations in C

Ayush Agarwal 1.4k Jan 6, 2023
Flutter package for creating awesome animations.

?? Simple Animations Simple Animations is a powerful package to create beautiful custom animations in no time. ?? fully tested ?? well documented ?? e

Felix Blaschke 879 Dec 31, 2022
Easily add staggered animations to your ListView, GridView, Column and Row children.

Flutter Staggered Animations Easily add staggered animations to your ListView, GridView, Column and Row children as shown in Material Design guideline

null 1.2k Jan 6, 2023
Fun canvas animations in Flutter based on time and math functions.

funvas Flutter package that allows creating canvas animations based on time and math (mostly trigonometric) functions. The name "funvas" is based on F

null 472 Jan 9, 2023
Organize your animations.

montage Organize your animations. Quickstart // 1. Define your animations const entrance = MontageAnimation( key: 'entrance', duration: Duration(s

Aloïs Deniel 14 Oct 19, 2022
A widget for stacking cards, which users can swipe horizontally and vertically with beautiful animations.

A widget for stacking cards, which users can swipe horizontally and vertically with beautiful animations.

HeavenOSK 97 Jan 6, 2023
A flutter package that adds support for vector data based animations.

animated_vector Description and inspiration A package that adds support for vector data based animations. The data format is heavily inspired from the

Potato Open Sauce Project 6 Apr 26, 2022
Simple reactive animations in your Flutter apps.

just.motion Flutter package to create organic motion transitions. Why? The Motion Value stateless hot reload status notifier Ease Motion Spring Motion

Roi Peker 49 Nov 14, 2022
Timer UI animation challenge from 'Flutter Animations Masterclass'

stopwatch_flutter An IOS stopwatch challenge from Flutter Animations Masterclass - Full Course What I learned; Use timer Use ticker Create custom shap

Ali Riza Reisoglu 11 Jan 4, 2023
A catalog of beautiful, reusable and elegant animations

Animations Catalog The goal of this project is to catalog and build multiple animation patterns with flutter. Budget App Animation Harley Swipe To Enl

null 3 Sep 6, 2021
🐱‍👤 Flutter-Animation 🔥 🔥 List Animated Staggered Animations

??‍?? Staggered Animations made with algeria ❤

Hmida 17 Nov 22, 2022
A collection of Animations that aims to improve the user experience for your next flutter project.

A collection of Animations that aims to improve the user experience for your next flutter project.

Ezaldeen Sahb 134 Dec 24, 2022
A Flutter Log In Page using Flare Animations

Bear_log_in An example built using JCToon's Flare File as a custom UI component. Bear will follow the cursor as you type or move it around. Overview T

Apurv Jha 14 Oct 19, 2022
A package to create nice and smooth animations for flutter

animation_director A package to create nice and smooth animations for flutter Introduction A simple package to build beautiful and smooth animations f

null 10 Nov 28, 2022
Widgets for creating Hero-like animations between two widgets within the same screen.

flutter_sidekick Widgets for creating Hero-like animations between two widgets within the same screen. Features Hero-like animations. Allow you to spe

Romain Rastel 291 Oct 21, 2022