All Projects → Norbert515 → Flutter_villains

Norbert515 / Flutter_villains

Licence: mit
Flexible and easy to use page transitions.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Flutter villains

UnityGUI
UGUI Panel Systems for navigation, animation and more
Stars: ✭ 80 (-72.79%)
Mutual labels:  transitions
stimulus-transition
Enter/Leave transition for stimulusJS, inspired by Vue/Alpine syntax
Stars: ✭ 34 (-88.44%)
Mutual labels:  transitions
motion-transitioning-objc
Light-weight API for building UIViewController transitions.
Stars: ✭ 24 (-91.84%)
Mutual labels:  transitions
libgdx-screenmanager
A screen manager for libgdx supporting transitions
Stars: ✭ 69 (-76.53%)
Mutual labels:  transitions
aholachek.github.io
My website
Stars: ✭ 53 (-81.97%)
Mutual labels:  transitions
transitionable-routes
Perform transitions when changing routes with React Router
Stars: ✭ 26 (-91.16%)
Mutual labels:  transitions
Just Animate
Making Animation Simple
Stars: ✭ 242 (-17.69%)
Mutual labels:  transitions
Material Motion Js
Reusable gestural interactions in JavaScript. In development.
Stars: ✭ 277 (-5.78%)
Mutual labels:  transitions
animated
🌊 Implicit animations for JavaFX.
Stars: ✭ 79 (-73.13%)
Mutual labels:  transitions
highway
Highway - A Modern Javascript Transitions Manager
Stars: ✭ 1,349 (+358.84%)
Mutual labels:  transitions
FluentTransitions
▶ Smooth UI animations & transitions for .NET
Stars: ✭ 27 (-90.82%)
Mutual labels:  transitions
Material-Design-Android
My stash for all things material, animations, typography, iconography, transitions, Animated VD, Color Palette API, UI design, and more.
Stars: ✭ 38 (-87.07%)
Mutual labels:  transitions
angular-super-gallery
AngularJS super image gallery
Stars: ✭ 46 (-84.35%)
Mutual labels:  transitions
react-component-transition
Easy animations between react component transitions.
Stars: ✭ 20 (-93.2%)
Mutual labels:  transitions
ionic-modal-custom-transitions
Add Custom Transitions to Ionic Modals.
Stars: ✭ 22 (-92.52%)
Mutual labels:  transitions
SwiftTweener
A pure Swift animation engine.
Stars: ✭ 74 (-74.83%)
Mutual labels:  transitions
kstatemachine
KStateMachine is a Kotlin DSL library for creating finite state machines (FSM) and hierarchical state machines (HSM).
Stars: ✭ 63 (-78.57%)
Mutual labels:  transitions
React Overdrive
Super easy magic-move transitions for React apps
Stars: ✭ 3,001 (+920.75%)
Mutual labels:  transitions
ScxmlEditor-Tutorial
ScxmlEditor - powerful tool for creating, editing and debugging scxml files
Stars: ✭ 33 (-88.78%)
Mutual labels:  transitions
transit
A simple Godot asset for smooth scene transitions.
Stars: ✭ 22 (-92.52%)
Mutual labels:  transitions

license stars forks Pub GitHub followers Twitter Follow Build Status

flutter_villains

What are heroes without villains?

profile-page

(Profile image from: https://unsplash.com/photos/pAs4IM6OGWI)

Check out the article.

What are villains?

You keep seeing beautiful page transitions but you think to yourself those are too much work?

Fear no more, villains are here to save you!

When doing animations when a page transition occurs you'd usally define an AnimationController in the initState() and start it there. You'd also have to wrap your widgets in AnimatedWidgets to react to the AnimationController. Besides this being a lot of boilerplate code which clogs up you precious widgets, animating on exit isn't as trivial.

Using this library you just wrap your widget you'd like to be animated when a page transition occurs in a Villain and everything is handled automatically.

Installation

dependencies:
  flutter_villains: "^1.2.1"

Run packages get and import:

import 'package:flutter_villains/villain.dart';

Assembling pages with style

Define animations to play when a page is opened.

Easy to use

      Villain(
        villainAnimation: VillainAnimation.fromBottom(
          relativeOffset: 0.4,
          from: Duration(milliseconds: 100),
          to: Duration(seconds: 1),
        ),
        animateExit: false,
        secondaryVillainAnimation: VillainAnimation.fade(),
        child: Divider(
          color: Colors.black,
          height: 32.0,
        ),
      ),

That's it. No TickerProviders, no AnimationControllers, no boilerplate, no worries. Remember the StaggeredAnimation tutorial? This is using SequenceAnimation internally and there is therefore no need to specify durations as portions of a time-frame. It just works.

With this basic setup the Divider fades in and moves up when a page transition occures (don't forget the VillainTransitionObserver more on that under Code).

Flexible

The animation you'd like to use is not premade? Make it yourself with a few lines of code!

  static VillainAnimation fade(
          {double fadeFrom = 0.0,
          double fadeTo = 1.0,
          Duration from = Duration.zero,
          Duration to: _kMaterialRouteTransitionLength,
          Curve curve: Curves.linear}) =>
      VillainAnimation(
          from: from,
          curve: curve,
          to: to,
          animatable: Tween<double>(begin: fadeFrom, end: fadeTo),
          animatedWidgetBuilder: (animation, child) {
            return FadeTransition(
              opacity: animation,
              child: child,
            );
          });

Every VillainAnimation needs an Animatable (most of the time it's a Tween) and an AnimatedWidget. Everything else is handled automatically.

Code

There are two way of playing your villains.

  1. If you want them to automatically play when a page transition occurs (you probably want that) then add this to your MaterialApp
    return new MaterialApp(
      navigatorObservers: [new VillainTransitionObserver()],
  1. Play villains in a given context manually.
    VillainController.playAllVillains(context);

Secondary Animation

You can play up to two animations per Villain. You can always wrap Villains inside each other for infinite animations!

    Villain(
      villainAnimation: VillainAnimation.fromBottomToTop(0.4, to: Duration(milliseconds: 150)),
      animateExit: false,
      secondaryVillainAnimation: VillainAnimation.fade,
      child: Text(
        "Hi",
        style: Theme.of(context).textTheme.body1,
      ),
    ),

Extras

Define whether the villain should play on entrance/ exit.

    animateEntrance: true,
    animateExit: true,

When using the VillainController manually, it checks this bool to determine whether it should animate.

  static Future playAllVillains(BuildContext context, {bool entrance = true})

Villains entering the page are decoupled from the page transition, meaning they can be as long as they want. On the other hand, if a villain leaves the page, the animation is driven by the page transition. This means:

  • The exit animation is always as long a the exit page transition
  • Setting the duration doesn't change anything

Examples

Take a look at the example folder for three nice examples.

Features:

The villain framework takes care of:

  • managing page transition callbacks
  • supplying animations
  • providing premade common animations

In contrast to real world villains, these villains are very easy to handle.

Controller

Currenty there are no controllers implemented to play individual villains by themselves. If you'd like to have that implemented I opened an issue discussing it. Check it out!

Icon from https://icons8.com/

Getting Started

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

For help on editing package code, view the documentation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].