直播系统源代码,用户在点击图片时,通过淡入淡出的方式放大图片的两种方法
直播系统源代码,用户在点击图片时,通过淡入淡出的方式放大图片的两种方法
第一种
1 | class AnimatedContainerApp extends StatefulWidget {<br> @override<br> _AnimatedContainerAppState createState() => _AnimatedContainerAppState();<br>}<br> <br> class _AnimatedContainerAppState extends State<AnimatedContainerApp> {<br> bool _visible = true;<br> @override<br> Widget build(BuildContext context) {<br> return MaterialApp(<br> home: Scaffold(<br> body: Center(<br> child: AnimatedOpacity(<br> //opacity=0.0透明<br> //opacity=1.0完全显示<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 500),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 200.0,<br> height: 200.0,<br> color: Colors.blue,<br> ),<br> ),<br> ),<br> floatingActionButton: FloatingActionButton(<br> child: Icon(Icons.play_arrow),<br> onPressed: () {<br> setState(() {<br> _visible = !_visible;<br> });<br> },<br> ),<br> ),<br> );<br> }<br>} |
第二种
1 | lass AnimatedContainerApp extends StatefulWidget {<br> @override<br> _AnimatedContainerAppState createState() => _AnimatedContainerAppState();<br>}<br> class _AnimatedContainerAppState extends State<AnimatedContainerApp> {<br> bool _visible = true;<br> @override<br> Widget build(BuildContext context) {<br> return MaterialApp(<br> home: Scaffold(<br> body: Center(<br> child: Stack(<br> children: <Widget>[<br> AnimatedOpacity(<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 3000),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 350.0,<br> height: 350.0,<br> color: Colors.blue.withOpacity(0.2),<br> child: Text('1'),<br> alignment: Alignment.bottomRight,<br> ),<br> curve: Curves.linear,<br> ),<br> AnimatedOpacity(<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 2500),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 300.0,<br> height: 300.0,<br> color: Colors.blue.withOpacity(0.3),<br> child: Text('2'),<br> alignment: Alignment.bottomRight,<br> ),<br> curve: Curves.linear,<br> ),<br> AnimatedOpacity(<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 2500),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 250.0,<br> height: 250.0,<br> color: Colors.blue.withOpacity(0.4),<br> child: Text('3'),<br> alignment: Alignment.bottomRight,<br> ),<br> curve: Curves.linear,<br> ),<br> AnimatedOpacity(<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 2000),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 200.0,<br> height: 200.0,<br> color: Colors.blue.withOpacity(0.5),<br> child: Text('4'),<br> alignment: Alignment.bottomRight,<br> ),<br> curve: Curves.linear,<br> ),<br> AnimatedOpacity(<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 1500),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 150.0,<br> height: 150.0,<br> color: Colors.blue.withOpacity(0.6),<br> alignment: Alignment.bottomRight,<br> child: Text('5'),<br> ),<br> curve: Curves.linear,<br> ),<br> AnimatedOpacity(<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 1000),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 100.0,<br> height: 100.0,<br> color: Colors.blue.withOpacity(0.64),<br> alignment: Alignment.bottomRight,<br> child: Text('6'),<br> ),<br> curve: Curves.linear,<br> ),<br> AnimatedOpacity(<br> opacity: _visible ? 1.0 : 0.0,<br> duration: Duration(milliseconds: 500),<br> // The green box must be a child of the AnimatedOpacity widget.<br> child: Container(<br> width: 50.0,<br> height: 50.0,<br> alignment: Alignment.bottomRight,<br> color: Colors.blue.withOpacity(0.98),<br> child: Text('7'),<br> ),<br> curve: Curves.linear,<br> ),<br> ],<br> ),<br> ),<br> floatingActionButton: FloatingActionButton(<br> child: Icon(Icons.play_arrow),<br> onPressed: () {<br> setState(() {<br> _visible = !_visible;<br> });<br> },<br> ),<br> ),<br> );<br> }<br>} |
以上就是直播系统源代码,用户在点击图片时,通过淡入淡出的方式放大图片的两种方法, 更多内容欢迎关注之后的文章
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现