短视频系统源码,根据手指指令放大或缩小图片

短视频系统源码,根据手指指令放大或缩小图片实现的相关代码

缩放功能

 

1
class ScaleAnimatedContent extends StatefulWidget {<br>  final Widget child;<br>  final bool show;<br>  const ScaleAnimatedContent({Key key, this.child, this.show = false})<br>      : super(key: key);<br>  @override<br>  ScaleAnimatedContentState createState() => ScaleAnimatedContentState();<br>}<br>class ScaleAnimatedContentState extends State<ScaleAnimatedContent><br>    with TickerProviderStateMixin {<br>  AnimationController animationController;<br>  Animation<double> animation;<br>  @override<br>  void initState() {<br>    animationController = new AnimationController(<br>      vsync: this,<br>      duration: new Duration(milliseconds: 600),<br>    );<br>    // animationSlideUp = new Tween(begin: 0.0,end: 1.0).animate(animationController);<br>    animation = Tween(begin: 0.0, end: 1.0).animate(animationController);<br>    if (widget.show) {<br>      animationController.forward();<br>    }<br>    super.initState();<br>  }<br>  @override<br>  void didUpdateWidget(ScaleAnimatedContent oldWidget) {<br>    if (widget != oldWidget) {<br>      if (widget.show && !oldWidget.show) {<br>        animationController.forward(from: 0.0);<br>      } else if (!widget.show) {<br>        animationController.reverse();<br>      }<br>    }<br>    super.didUpdateWidget(oldWidget);<br>  }<br>  @override<br>  Widget build(BuildContext context) {<br>    return ScaleTransition(<br>      scale: animation,<br>      child: widget.child,<br>    );<br>  }<br>  @override<br>  void dispose() {<br>    animationController.dispose();<br>    super.dispose();<br>  }<br>}

滑动效果

 

1
class SlideAnimatedContent extends StatefulWidget {<br>  final Widget child;<br>  final bool show;<br>  const SlideAnimatedContent({Key key, this.child, this.show = false})<br>      : super(key: key);<br>  @override<br>  SlideAnimatedContentState createState() => SlideAnimatedContentState();<br>}<br>class SlideAnimatedContentState extends State<SlideAnimatedContent><br>    with TickerProviderStateMixin {<br>  AnimationController animationController;<br>  Animation<Offset> animationSlideUp;<br>  @override<br>  void initState() {<br>    animationController = new AnimationController(<br>      vsync: this,<br>      duration: new Duration(milliseconds: 600),<br>    );<br>    animationSlideUp = new Tween(<br>      begin: Offset(0.0, 5.0),<br>      end: Offset(0.0, 0.0),<br>    ).animate(CurvedAnimation(parent: animationController, curve: Curves.ease));<br>    if (widget.show) {<br>      animationController.forward();<br>    }<br>    super.initState();<br>  }<br>  @override<br>  void didUpdateWidget(SlideAnimatedContent oldWidget) {<br>    if (widget != oldWidget) {<br>      if (widget.show && !oldWidget.show) {<br>        animationController.forward(from: 0.0);<br>      } else if (!widget.show) {<br>        animationController.reverse();<br>      }<br>    }<br>    super.didUpdateWidget(oldWidget);<br>  }<br>  @override<br>  Widget build(BuildContext context) {<br>    return SlideTransition(<br>      position: animationSlideUp,<br>      child: FadeTransition(<br>        opacity: animationController,<br>        child: widget.child,<br>      ),<br>    );<br>  }<br>  @override<br>  void dispose() {<br>    animationController.dispose();<br>    super.dispose();<br>  }<br>}

 

以上就是 短视频系统源码,根据手指指令放大或缩小图片实现的相关代码,更多内容欢迎关注之后的文章

 

posted @   云豹科技-苏凌霄  阅读(108)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示