FLUTTER Development - Animation - Custom Animation

tags: Flutter  Animation  

Why do you want to customize an animation?

  • When the animation provided by the system does not meet business needs, we need our own custom animation.
  • Enhance the ability of custom components through custom animations

Two custom animation process

  1. Inherit the StateFulWidget to complete the drawing of the animation interface
  2. setState Mid-action execution and status monitoring and refresh UI
  3. disposeRelease resource

Three samples

3.1 code

// Entrance location
Future<void> main() async {
  runApp(Home());
}
class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(body: Center(child: AnimationDemo(),),),
    );
  }
}
 // Custom animation
class AnimationDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _AnimationDemo();
}

class _AnimationDemo extends State<AnimationDemo> with SingleTickerProviderStateMixin {
  AnimationController _animationController;
  Animation _animation;

  @override
  void initState() {
    super.initState();
    _animationController = AnimationController(duration: Duration(seconds: 2), vsync: this);
    _animation = Tween(begin: .5, end: .1).animate(_animationController);
         _AnimationController.forward (); // Start animation
  }

  @override
  Widget build(BuildContext context) {
    return  ScaleTransition(
      scale: _animation,
      child: Container(height: 200, width: 200, color: Colors.red,),
    );
  }

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

3.2 renderings

Intelligent Recommendation

FLUTTER Development - Animation - Tween

I. Overview Tween animation, also called complement animation Tween has two keyframes, begin start frames, end frames, and complement-up frames in Begin and END completed animation effects Common Twee...

FLUTTER Development - Animation - AnimationController

I. Overview The TWEEN animation controller can perform the corresponding animation effect based on the interval value. Control the start of the animation, stop, you can also get the operation status o...

FLUTTER Development - Animation - Lottie

I. Overview Lottie is an ARIBNB open source for high-performance animation library for Android, iOS, etc. The flutter native bank does not support Lottie, but the animation effect of Lottie can be imp...

FLUTTER Development - Animation - Nima

I. Overview NIMA is a 2D vector animation tool for Skia-rendering NIMA's use operation is basically the same as Flare NIMA file decompression is included.nma.bytesFile and.pngImage file, specified whe...

FLUTTER Development - Animation - RIVE

I. Overview Rive is a FLARE upgrade version, is a real-time interaction design and animation tool. The reciprion of the file is.riv, Use it when loading animation isRive Flutter runtime Rive supports ...

More Recommendation

FLUTTER animation custom animation component - Flutterlayout

Preface: This article will customize a FLUTTERWIDGET animation component, flutter has a tremark meaning What is the animateDWidget and animatedbuilder before this? How to use So this article is a quit...

Flutter Animation animation development-reverse reverse playback

We know that AnimationController.forward () can play animation in forward direction, if you want to play animation in reverse, you can call AnimationController.reverse () Step on the pit Immediately w...

Flutter Animation animation development-repeat loop playback

Introduction We know that AnimationController.forward () can play the animation in the forward direction, and AnimationController.reverse () can play the animation in the reverse direction. If you wan...

FLUTTER Development - Animation - Transition Animation Hero

I. Overview Hero animation is also called transition animation Excessive animation: When the user clicks on a picture, switch to another page, this page also has this picture. Di Hero 2.1 Constructor ...

FLUTTER Development - Animation - List Animation AnimatedList

I. Overview List animation, AnimatedList animation, is a display list data when component animation When the data of the list changes (when adding or deleted), show this change in the form of animatio...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top