[英]flutter TweenAnimationBuilder is not working
我想只在用户想要查看产品详细信息时运行一个标签 animation 水平一次,但有一个销售标签但没有任何反应。 我查看了所有解决方案,但无法解决自己。
这是教程,我想如何移动线,这是我想移动的堆栈图像
TweenAnimationBuilder(
tween: Tween<double>(
begin: 0.0,
end: MediaQuery.of(context).size.width),
duration: const Duration(milliseconds: 4000),
builder: (context, double i, _) {
return Stack(
children: [
Container(
width: 50,
height: 20,
color: Colors.black,
child: const Center(
child: Text(
"SALE",
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w500,
color: Colors.white),
),
),
),
SizedBox(
height: 20,
width: 115,
child: CustomPaint(
painter: PriceTagPaint(),
child: Center(
child: Padding(
padding: const EdgeInsets.only(
right: 16.0),
child: Align(
alignment: Alignment.centerRight,
child: Text(
widget.listModel.sale!,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 10,
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
),
),
),
),
],
);
}),
我在哪里犯错?
您需要使用Positioned
小部件将小部件放置在Stack
中。
TweenAnimationBuilder(
tween: Tween<double>(
begin: 0.0, end: MediaQuery.of(context).size.width),
duration: const Duration(milliseconds: 4000),
builder: (context, double i, _) {
return Stack(
children: [
///.....
Positioned(
top: i,
child: Container(
width: 50,
height: 20,
color: Colors.black,
child: const Center(
child: Text(
"SALE",
style: TextStyle(
fontSize: 10,
fontWeight: FontWeight.w500,
color: Colors.white),
),
),
),
),
],
);
}),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.