Flutter仿网易云音乐:播放界面,技术详细介绍

本文详细介绍了如何使用Flutter构建网易云音乐播放界面,包括黑胶唱头的旋转动画、黑胶唱片的旋转效果,以及下部控制器和进度条的实现。文章通过具体的代码示例展示了如何创建旋转动画,如PivotTransition和RotationTransition,并提供了播放控制组件的实现,如AudioPlayer的使用。此外,还提及作者的个人背景和Android开发经验。
摘要由CSDN通过智能技术生成

child: new Container(
decoration: new BoxDecoration(
color: Colors.grey.shade900,
),
),
),
)),


]

这里的高斯模糊sigmaX和sigmaY的值选择了10,然后透明度为0.6,颜色为grey.shade900。

2.黑胶唱头的旋转动画

关于动画的知识这里就不做详细介绍了,可以参考官方文档传送门

自定义动画组件在needle_anim.dart文件里。 这里将动画和组件解耦,分别定义了动画过程类PivotTransition,顾名思义围绕一个支点旋转,继承自AnimatedWidget

支点定在child组件的topcenter位置。 注意turns不能为空,需要根据turns的值计算旋转绕过的周长,围绕Z轴旋转。

class PivotTransition extends AnimatedWidget {
/// 创建旋转变换
/// turns不能为空.
PivotTransition({
Key key,
this.alignment: FractionalOffset.topCenter,
@required Animation turns,
this.child,
}) : super(key: key, listenable: turns);

/// The animation that controls the rotation of the child.
/// If the current value of the turns animation is v, the child will be
/// rotated v * 2 * pi radians before being painted.
Animation get turns => listenable;

/// The pivot point to rotate around.
final FractionalOffset alignment;

/// The widget below this widget in the tree.
final Widget child;

@override
Widget build(BuildContext context) {
final double turnsValue = turns.value;
final Matrix4 transform = new Matrix4.rotationZ(tu

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值