simple_animations 1.3.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 98

Simple Animations #

Awesome Flutter Pub

Simple Animations is a package for Flutter to boost your animation productivity by simplifying the way to create animations.

Project goal #

Flutter has a strong and flexible foundation of animation capabilities.

But even small animations feel verbose and blow up your code base. Animations are one of the most desired aspects of Flutter, while being difficult to master.

Simple Animation's goal is to solve this issue, by

  • simplifying the way to creates custom animations,
  • softly dipping developers into the animation topic,
  • offering a lot of documentation and examples.

Getting started #

There are multiple ways to get started:

Examples #

Typewriter Box #

This custom animation seems simple but it's rather complex:

hello-flutter-example

It's combining a staggered animation sequence with an enduring animation:

  • At the beginning it animates the height of a box. After that it increases the width.
  • While increasing the width a typewriter-like animated underscore appears and persists.
  • Shortly before the width reaches it's final size, it starts to type-write a text.

With traditional Flutter animation classes this will end in a huge StatefulWidget with multiple AnimationController, Tweens and all that initState and onDispose overhead.

With simple_animation you can do it stateless just by using some fancy ControlledAnimation widgets.

The whole animation just takes about 60 lines of code while maintaining readability. (You can find the source code here. I only counted the lines that are responsible for the animation.)

Pub Example Tab #

This is the example from the example page (pub.dartlang.org):

pub-example-tab

Example App #

You find these and other examples in Example App.

fancy-background

fade-in

1.3.4 #

  • Fixed documentation: missing line about manual creation of AnimationControllerX

1.3.1 - 1.3.3 #

  • Upgraded to Flutter 1.7 and Dart 2.4

1.3.0 #

  • Upgraded to Flutter 1.5 and Dart 2.3

New features #

  • AnimationControllerX a new, powerful AnimationController
  • AnimationControllerMixin to easily setup AnimationControllerX
  • 5 types of AnimationTasks to use for AnimationControllerX

1.2.0 #

New features #

  • Rendering a widget for building of continuous animations
  • AnimationProgress a utility class that helps you with Duration-based Animations

1.1.1 #

  • Fixed strange effect when rebuilding a ControlledAnimation with playback set to Playback.MIRROR

1.1.0 #

New features #

  • New property startPosition for ControlledAnimation widget: you can now specify the initial start position (time) of the animation. This is useful for designing interactive UI elements.

1.0.0 #

  • Initial release

New features #

  • ControlledAnimation: Widget for simple tween-based custom animations
  • MultiTrackTween: Animatable for tweening multiple properties at once

0.x #

  • Setting up the project

example/main.dart

// "This is just one possibility what
//     you can do with simple_animations!"
//
// Documentation:
//   https://github.com/felixblaschke/simple_animations/tree/master/documentation
//
// Example App:
//   https://github.com/felixblaschke/simple_animations_example_app
//

import 'dart:math';
import 'package:flutter/material.dart';
import 'package:simple_animations/simple_animations.dart';

void main() => runApp(Example());

class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(child: Center(child: buildAnimation())),
      ),
    );
  }

  final tween = MultiTrackTween([
    Track("size").add(Duration(seconds: 4), Tween(begin: 0.0, end: 150.0)),
    Track("color")
        .add(Duration(seconds: 2),
            ColorTween(begin: Colors.red, end: Colors.blue),
            curve: Curves.easeIn)
        .add(Duration(seconds: 2),
            ColorTween(begin: Colors.blue, end: Colors.green),
            curve: Curves.easeOut),
    Track("rotation").add(Duration(seconds: 1), ConstantTween(0.0)).add(
        Duration(seconds: 3), Tween(begin: 0.0, end: pi / 2),
        curve: Curves.easeOutSine)
  ]);

  Widget buildAnimation() {
    return ControlledAnimation(
      playback: Playback.MIRROR,
      duration: tween.duration,
      tween: tween,
      builder: (context, animation) {
        return Transform.rotate(
          angle: animation["rotation"],
          child: Container(
            width: animation["size"],
            height: animation["size"],
            color: animation["color"],
          ),
        );
      },
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  simple_animations: ^1.3.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:simple_animations/simple_animations.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
96
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
98
Learn more about scoring.

We analyzed this package on Nov 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test