[英]flutter TweenAnimationBuilder is not working
I want to run a tag animation horizontal one time only when user want to see detail of product there is a Tag of sale but nothing happen.我想只在用户想要查看产品详细信息时运行一个标签 animation 水平一次,但有一个销售标签但没有任何反应。 I've looked all solutions but couldn't solve myself.
我查看了所有解决方案,但无法解决自己。
Here is the tutorial , how I want to move line and this is image of stack I want to move这是教程,我想如何移动线,这是我想移动的堆栈图像
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),
),
),
),
),
),
),
],
);
}),
Where I'm making mistake?我在哪里犯错?
You need to use Positioned
widget to place the widget in Stack
.您需要使用
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.