标签:opacity 1.0 淡入淡出 0.0 visible child AnimatedOpacity 源代码 图片
直播系统源代码,用户在点击图片时,通过淡入淡出的方式放大图片的两种方法
第一种
class AnimatedContainerApp extends StatefulWidget {
@override
_AnimatedContainerAppState createState() => _AnimatedContainerAppState();
}
class _AnimatedContainerAppState extends State<AnimatedContainerApp> {
bool _visible = true;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: AnimatedOpacity(
//opacity=0.0透明
//opacity=1.0完全显示
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 500),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 200.0,
height: 200.0,
color: Colors.blue,
),
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.play_arrow),
onPressed: () {
setState(() {
_visible = !_visible;
});
},
),
),
);
}
}
第二种
lass AnimatedContainerApp extends StatefulWidget {
@override
_AnimatedContainerAppState createState() => _AnimatedContainerAppState();
}
class _AnimatedContainerAppState extends State<AnimatedContainerApp> {
bool _visible = true;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Stack(
children: <Widget>[
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 3000),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 350.0,
height: 350.0,
color: Colors.blue.withOpacity(0.2),
child: Text('1'),
alignment: Alignment.bottomRight,
),
curve: Curves.linear,
),
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 2500),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 300.0,
height: 300.0,
color: Colors.blue.withOpacity(0.3),
child: Text('2'),
alignment: Alignment.bottomRight,
),
curve: Curves.linear,
),
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 2500),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 250.0,
height: 250.0,
color: Colors.blue.withOpacity(0.4),
child: Text('3'),
alignment: Alignment.bottomRight,
),
curve: Curves.linear,
),
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 2000),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 200.0,
height: 200.0,
color: Colors.blue.withOpacity(0.5),
child: Text('4'),
alignment: Alignment.bottomRight,
),
curve: Curves.linear,
),
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 1500),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 150.0,
height: 150.0,
color: Colors.blue.withOpacity(0.6),
alignment: Alignment.bottomRight,
child: Text('5'),
),
curve: Curves.linear,
),
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 1000),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 100.0,
height: 100.0,
color: Colors.blue.withOpacity(0.64),
alignment: Alignment.bottomRight,
child: Text('6'),
),
curve: Curves.linear,
),
AnimatedOpacity(
opacity: _visible ? 1.0 : 0.0,
duration: Duration(milliseconds: 500),
// The green box must be a child of the AnimatedOpacity widget.
child: Container(
width: 50.0,
height: 50.0,
alignment: Alignment.bottomRight,
color: Colors.blue.withOpacity(0.98),
child: Text('7'),
),
curve: Curves.linear,
),
],
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.play_arrow),
onPressed: () {
setState(() {
_visible = !_visible;
});
},
),
),
);
}
}
以上就是直播系统源代码,用户在点击图片时,通过淡入淡出的方式放大图片的两种方法, 更多内容欢迎关注之后的文章
标签:opacity,1.0,淡入淡出,0.0,visible,child,AnimatedOpacity,源代码,图片 来源: https://www.cnblogs.com/yunbaomengnan/p/15867754.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。