当前位置:网站首页>Flutter records and learns different animations (1)
Flutter records and learns different animations (1)
2022-07-30 03:44:00 【Mr-dream】
1. Classification of animations
There are two main types in flutter
Motion tweening: In an animation tween, a start and end point, a timeline, and a curve for transition time and speed are defined.It is then up to the framework to calculate how to transition from the start point to the end point.
Physical animation: In physics-based animation, motion is simulated to resemble real-world behavior.
Second, common core classes in animation
a. Animation: Used to monitor the state of animation and get the animation change value.
b. Aniamtable: Calculate the real value of the animation according to the given start value and end value.
c. AnimationController: Animation controller, which controls the animation start, pause, end and other states.Inherit Animation.A vsync parameter needs to be passed to prevent off-screen animations from consuming unnecessary resources when vsync exists.
d. Tween: Change value overloader, such as color change value, numerical change value.Inherit Animatable
e. addListeners and addStatusListeners: The former is mainly used to monitor changes in animation values, while the latter is mainly used to monitor changes in animation status, such as pause, start, end, and complete.
f. CurvedAnimation: Used to define nonlinear curve animations, such as acceleration, uniform speed, acceleration and deceleration, etc., to indicate how the animation runs.Inherited from Animation, which is equivalent to wrapping the animation value, and the interpolated value of the animation can be directly obtained through .value.
g.Curve: animation interpolator (used to change the value of the animation, such as calculating the current value of the animation, put it as the x value into the function to calculate the value of y) the custom interpolator inherits it
Three, the use of animation
pseudocode
AnimationController _controller;Animation<double> _animation;@overridevoid initState() {super.initState();_controller = AnimationController(duration: Duration(milliseconds: 2000), vsync:this);_animation = CurvedAnimation(parent: _controller,curve: Curves.fastOutSlowIn,);_animation =Tween(begin: 0 end: 100).animate(_animation);_controller.addListener((){setState(() { });}} ;_controller.forward();}@overrideWidget build(BuildContext context) {return Container(width: _animation.value,color: Colors.red,);}Four. Summary
The animation written in this way has a big disadvantage, that is, it needs to use setState to continuously refresh the page according to the animation value.
When the page is more complicated, if it is not good, it will lead to performance problems.So he needs to be taken out.This is the two officially encapsulated animation classes to be mentioned later, namely AnimatedWidget and AnimatedBuilder.
边栏推荐
猜你喜欢

OpenFeign implementation downgrade

Ansible简介(详细)特性+优点+设计理念+应用领域+系统架构+工作原理+任务执行流程

分类之决策树分类

小程序毕设作品之微信积分商城小程序毕业设计成品(6)开题答辩PPT

朴素贝叶斯分类

SQL 入门之第一讲——MySQL 8.0.29安装教程(windows 64位)

Answer these 3 interview questions correctly, and the salary will go up by 20K

小程序毕设作品之微信二手交易小程序毕业设计成品(2)小程序功能

Mini Program Graduation Works WeChat Points Mall Mini Program Graduation Design Finished Products (6) Question Opening and Defense PPT

OpenFeign实现负载均衡
随机推荐
3.nodejs--modularization
[Flink] How to determine the cluster planning size from development to production launch?
【SQL】按某个关联列用一张表的数据更新另一张表
NLP自然语言处理(一)
Hystrix 服务熔断
Problems caused by List getting the difference
JIT vs AOT
route filter
SQLSERVER将子查询数据合并拼接成一个字段
Organizations Going Online: A New Trend in Organizational Digital Transformation
TCP congestion control technology and acceleration principle of BBR
spicy (1) basic definition
Mini Program Graduation Works WeChat Second-hand Trading Mini Program Graduation Design Finished Works (6) Question Opening Reply PPT
淘宝/天猫获得淘宝店铺详情 API
sublime text 3 设置
组织在线化:组织数字化变革的新趋势
Sentinel 流量防卫兵
一起来学习flutter 的布局组件
操作配置:如何在一台服务器中以服务方式运行多个EasyCVR程序?
小程序毕设作品之微信二手交易小程序毕业设计成品(8)毕业设计论文模板