当前位置:网站首页>Flutter uses animatedswitcher to switch scenes
Flutter uses animatedswitcher to switch scenes
2022-07-19 13:30:00 【InfoQ】
Preface
AnimatedSwitcher
AnimatedSwitcher Introduce
AnimatedSwitcherFadeTransitionAnimatedSwitcherconst AnimatedSwitcher({
Key? key,
this.child,
required this.duration,
this.reverseDuration,
this.switchInCurve = Curves.linear,
this.switchOutCurve = Curves.linear,
this.transitionBuilder = AnimatedSwitcher.defaultTransitionBuilder,
this.layoutBuilder = AnimatedSwitcher.defaultLayoutBuilder,
})
AnimatedSwitcherdurationreverseDuration: Reverse duration , That is, the duration of switching to the old component , If you don't set it, it's likedurationAgreement .
switchInCurve: Cut into the animation curve , That is, the curve into which the new component switches ;
switchOutCurve: Cut out the animation curve , That is, the curve when the old component is switched out ;
transitionBuilder: Toggle transition animation construction , It's a function , The definition is as follows , You can use this method to build your own switching effect .
typedef AnimatedSwitcherTransitionBuilder = Widget Function(Widget child, Animation<double> animation);
layoutBuilder: You can set the layout of new components in the component tree , It's also a function :
typedef AnimatedSwitcherLayoutBuilder = Widget Function(Widget? currentChild, List<Widget> previousChildren);
defaultLayoutBuilderstatic Widget defaultLayoutBuilder(Widget? currentChild, List<Widget> previousChildren) {
return Stack(
children: <Widget>[
...previousChildren,
if (currentChild != null) currentChild,
],
alignment: Alignment.center,
);
}
AnimatedSwitcherAnimatedSwitcherWidgetcanUpdatestatic int _debugConcreteSubtype(Widget widget) {
return widget is StatefulWidget ? 1 :
widget is StatelessWidget ? 2 :
0;
}
KeyValueKeyapplication
SizeTransition class AnimatedSwitcherDemo extends StatefulWidget {
AnimatedSwitcherDemo({Key? key}) : super(key: key);
@override
_AnimatedSwitcherDemoState createState() => _AnimatedSwitcherDemoState();
}
class _AnimatedSwitcherDemoState extends State<AnimatedSwitcherDemo> {
Widget? _animatedWidget;
bool test = false;
@override
void initState() {
super.initState();
_animatedWidget = ClipOval(
child: Image.asset('images/beauty.jpeg'),
key: ValueKey(1),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AnimatedSwticher'),
brightness: Brightness.dark,
backgroundColor: Colors.black,
),
backgroundColor: Colors.black,
body: Center(
child: Container(
padding: EdgeInsets.all(10.0),
child: AnimatedSwitcher(
child: _animatedWidget,
duration: const Duration(milliseconds: 1000),
transitionBuilder: (child, animation) {
return SizeTransition(
sizeFactor: animation,
child: child,
);
},
),
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.play_arrow),
onPressed: () {
setState(() {
test = !test;
_animatedWidget = test
? ClipOval(
child: Image.asset('images/beauty2.jpeg'),
key: ValueKey(2),
)
: ClipOval(
child: Image.asset('images/beauty.jpeg'),
key: ValueKey(1),
);
});
},
),
);
}
}
summary
AnimatedSwitcherAnimatedSwitcherKey
边栏推荐
- [pyGame learning notes] 6 Cursor mouse cursor
- 使用case语句时会产生锁存器的情况
- sqli-labs(less-11)
- Uio-66 | fe3o4/cu3 (BTC) 2 metal organic framework (MOF) nanocomposites supported on silver nanoparticles | nagdf4:yb, er upconversion nanoparticles @zif-8
- 大家好,问一下数据库没开始binlog如何实时同步么,有没有好的方案
- Qt之使用QLisView实现QQ登录历史列表
- Atmospheric non isohalo effect
- 动手学深度学习(第二版)注释后代码【持续更新】
- codeforce:A. Doremy‘s IQ【反向贪心】
- XML建模(简单易学)
猜你喜欢
[email protected] (FE) composite nan"/>Metal organic framework material / polymer composite zif-8/p (TDA co HDA) | zinc oxide [email protected] (FE) composite nan

codeforce:A. Difference Operations【数学思维】
![[Yugong series] July 2022 go teaching course 012 forced type conversion](/img/7d/79f3e3e9fc73ee860b9607b7ebbb84.png)
[Yugong series] July 2022 go teaching course 012 forced type conversion

onvif协议相关:4.1.4 WS-Username token方式获取流地址
![[Tencent blue whale] the seventh 7.24 operation and maintenance day holiday greetings ~ come and make a wish~](/img/60/ab96abd599230078b19abad0aecba2.png)
[Tencent blue whale] the seventh 7.24 operation and maintenance day holiday greetings ~ come and make a wish~

C语言进阶——字符函数和字符串函数

Li Kou 198-213 looting Ⅰ, Ⅱ - Dynamic Planning

Reg of sequential logic and combinatorial logic
![[JS reverse crawler] - Youdao translation JS reverse practice](/img/cd/a44445422e2911b005519b5ec30ec0.jpg)
[JS reverse crawler] - Youdao translation JS reverse practice

(pc+wap) dream weaving template clothing dress website
随机推荐
[pyGame learning notes] 7 event
光大期货网上开户安全吗?有没有开户指引?
onvif协议相关:2.1.2 none方式获取截图url
Is it safe for Everbright futures to open an account online? Are there any account opening guidelines?
Reg of sequential logic and combinatorial logic
Supported metal organic framework zif-8 / graphene oxide hydrogen storage material | titanium dioxide /zif-8 composite | silicon dioxide @zif8 nano material
Framework construction of business card management
[record of question brushing] 13 Roman numeral to integer
Gold nanoparticles modified mil-101 framework material (AuNPs / mil-101) / loaded cof-tppa-1 (Au NPs / cof-tppa-1) | Qiyue reagent
mysql排序索引失效?
【南瓜书ML】(task2)线性模型的数学推导(最小二乘估计、广义瑞利商、极大似然估计等)
Lanthanide metal organic skeleton( [email protected] )|Rhodamine 6G modified MOF material | catalase @zif composite | MOF
力扣413-等差数列划分——动态规划
eth入门之运行节点
A general memory management driver code is sorted out
C语言进阶——自定义类型:结构体 枚举 联合
XML file parsing
Attachment handling of SAP Fiori
npm err! ant-design- [email protected] build: `umi build`
【Pygame 学习笔记】6.Cursor 鼠标光标