在码农的世界里,优美的应用体验,来源于程序员对细节的处理以及自我要求的境界,年轻人也是忙忙碌碌的码农中一员,每天、每周,都会留下一些脚印,就是这些创作的内容,有一种执着,就是不知为什么,如果你迷茫,不妨来瞅瞅码农的轨迹。
本文章的效果图:源码
main() {
runApp(MaterialApp(
home: SignSwiperPage(),
));
}
class SignSwiperPage extends StatefulWidget {
@override
_SignSwiperPageState createState() => _SignSwiperPageState();
}
class _SignSwiperPageState extends State<SignSwiperPage>
with SingleTickerProviderStateMixin {
}
接下来的代码都在 _SignSwiperPageState中编写
//动画控制器
AnimationController _animationController;
@override
void initState() {
super.initState();
//创建
_animationController = new AnimationController(
vsync: this, duration: Duration(milliseconds: 2000));
//添加到事件队列中
Future.delayed(Duration.zero, () {
//动画重复执行
_animationController.repeat();
});
}
@override
void dispose() {
//销毁
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Swiper Demo"),
),
backgroundColor: Colors.white,
//居中
body: Center(
//层叠布局
child: Stack(
children: [
//第一层的背景 圆形剪裁
ClipOval(
child: Container(
width: 200,
height: 200,
color: Colors.green,
),
),
//第二层的扫描
buildRotationTransition(),
],
),
),
);
}
RotationTransition 用来实现旋转动画
RotationTransition buildRotationTransition() {
//旋转动画
return RotationTransition(
//动画控制器
turns: _animationController,
//圆形裁剪
child: ClipOval(
//扫描渐变
child: Container(
width: 200,
height: 200,
decoration: BoxDecoration(
//扫描渐变
gradient: SweepGradient(colors: [
Colors.white.withOpacity(0.2),
Colors.white.withOpacity(0.6),
]),
),
),
),
);
}
完毕
不局限于思维,不局限语言限制,才是编程的最高境界。
以小编的性格,肯定是要录制一套视频的,随后会上传
有兴趣 你可以关注一下 西瓜视频 --- 早起的年轻人
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。