我最近在使用Google Flutter进行一个项目,想知道是否可以在小部件动画中应用运动模糊。这可以使动画更加逼真和舒缓。我没有找到任何相关的资源。
有人尝试过吗?
我最近在使用Google Flutter进行一个项目,想知道是否可以在小部件动画中应用运动模糊。这可以使动画更加逼真和舒缓。我没有找到任何相关的资源。
有人尝试过吗?
RotationTransition(
turns: Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: animationController,
curve: Curves.easeInOutQuad,
),
),
child: ...,
),
Stack(
children: [
FadeTransition(
opacity: Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(parent: animationController, curve: const FadeCurve(),
),
),
child: Image.asset(
"assets/images/image.png",
),
),
FadeTransition(
opacity: Tween(begin: 0.0, end: 1.0).animate(
CurvedAnimation(parent: animationController, curve: const FadeCurve(),
),
),
child: Image.asset(
"assets/images/image_withMB.png",
),
),
],
),
然后我创建了一个自定义的 Curve
,根据旋转速度改变不透明度。
class FadeCurve extends Curve {
const FadeCurve();
@override
double transform(double t) {
if (t <= 0.5) return pow(2 * t, 2).toDouble();
return pow(2 - 2 * t, 2).toDouble();
}
}
BackdropFilter
而不使用预先静态模糊图像来替换它,那么应该可以解决问题。提示:如果您将BackdropFilter
的sigma值增加X而不是Y或类似的值,则会更接近实际运动模糊。 - Sahaj Rana