当前位置:网站首页>来,滑动到下一个小姐姐
来,滑动到下一个小姐姐
2022-07-22 22:08:00 【InfoQ】
AnimatedBuilderAnimatedWidgetSlideTransition
SlideTransition 介绍
SlideTransitionAnimatedWidgetconst SlideTransition({
Key? key,
required Animation<Offset> position,
this.transformHitTests = true,
this.textDirection,
this.child,
})
positionAnimationControllerAnimationSlideTransitionAnimationControllerAnimation<Offset>Offsetnew_x = width * dx;
new_y = height * dy;
dxdxdydxdy示例效果实现
SlideTransitionAnimationControllerforwardreverseclass SlideTransitionDemo extends StatefulWidget {
SlideTransitionDemo({Key? key}) : super(key: key);
@override
_SlideTransitionDemoState createState() => _SlideTransitionDemoState();
}
class _SlideTransitionDemoState extends State<SlideTransitionDemo>
with SingleTickerProviderStateMixin {
bool _forward = true;
final begin = Offset.zero;
// 第一张图片结束位置移出右侧屏幕
final end1 = Offset(1.1, 0.0);
// 第二张图片的初始位置在左侧屏幕
final begin2 = Offset(-1.1, 0.0);
late Tween<Offset> tween1 = Tween(begin: begin, end: end1);
late Tween<Offset> tween2 = Tween(begin: begin2, end: begin);
late AnimationController _controller =
AnimationController(duration: const Duration(seconds: 1), vsync: this);
//使用自定义曲线动画过渡效果
late Animation<Offset> _animation1 = tween1.animate(
CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
),
);
late Animation<Offset> _animation2 = tween2.animate(CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
));
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('SlideTransition'),
brightness: Brightness.dark,
backgroundColor: Colors.black,
),
backgroundColor: Colors.black,
body: Center(
child: Container(
padding: EdgeInsets.all(10.0),
child: Stack(
children: [
SlideTransition(
child: ClipOval(
child: Image.asset('images/beauty.jpeg'),
),
position: _animation1,
),
SlideTransition(
child: ClipOval(
child: Image.asset('images/beauty2.jpeg'),
),
position: _animation2,
),
],
),
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.swap_horizontal_circle_sharp),
onPressed: () {
setState(() {
if (_forward) {
_controller.forward();
} else {
_controller.reverse();
}
_forward = !_forward;
});
},
),
);
}
}
总结
SlideTransitionSlideTransition
边栏推荐
猜你喜欢

Niuke Xiaobai month race 53

项目升级遇到的坑

Detailed analysis of the 110th blog of the fledgling Xiao Li in stm32__ NVIC_ Setprioritygrouping (uint32_t prioritygroup) function

QT document reading notes - qaudioinput & qaudioformat parsing and examples
![[reading notes > statistics] 12-01 construction of confidence interval - Introduction to the concept of confidence interval](/img/27/0431eeedbffdba1bdf4bb015082219.png)
[reading notes > statistics] 12-01 construction of confidence interval - Introduction to the concept of confidence interval

MySQL消息队列表结构

Can PHP split arrays

机器学习笔记 - 基于深度学习(HomographyNet)的图像单应性估计

数据库基础及安装

Fastapi learning (II) -- fastapi+jinjia2 template rendering web page (jump back to the rendering page)
随机推荐
互联网流量编排方案
学习总结 | 真实记录 MindSpore 两日集训营能带给你什么(一)!
Talking about performance optimization: analysis and optimization of APP startup process
HCIP --- BGP综合实验
Introduction to JVM monitoring tools jstack, jconsole, Jinfo, jmap, JDB, jstat
Google Earth engine app - a complete map legend app (land use classification of western United States)
Can PHP array subscripts only start from 0
张宇高数30讲总结
SQL报错盲注实例分析
General, special and hidden attributes of the file (instance generates animation)
yolov5 test. Py broken pipe error: [errno 32] broken pipe problem solving
如何用C语言实现简单职工信息管理系统
Experiment 4 DPCM
Reading notes - > statistics] construction of 12-02 confidence interval -t distribution concept introduction
How to use C language to realize simple employee information management system
Codeforces round 809 (Div. 2) (Questions C and D1)
如何高效安装MindSpore的GPU版本
wps数据拆分
Live broadcast preview | live broadcast Seminar on open source security governance models and tools
Fastapi learning (II) -- fastapi+jinjia2 template rendering web page (jump back to the rendering page)