条件满足后如何让卡片自动旋转?
Posted
技术标签:
【中文标题】条件满足后如何让卡片自动旋转?【英文标题】:How to make the card rotate after the condition is met automatically? 【发布时间】:2021-09-06 10:25:08 【问题描述】:Widget buildTarget(CardItem? item)
if (item != null)
return Transform(
alignment: FractionalOffset.center,
transform: Matrix4.identity()
..setEntry(3, 2, 0.002)
..rotateY(pi*0.5),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
child: Container(
height: 150,
width: 150,
color: Colors.white,
child:Center(child: Image.asset(item.imageUrl)),
),
),
));
else
return Text('Errors');
【问题讨论】:
【参考方案1】:double _rotateFactor = 0.5;
void _changeAngle(double factor)
_rotateFactor = factor;
setState(());
...
Widget buildTarget(CardItem? item)
if (item != null)
return Transform(
alignment: FractionalOffset.center,
transform: Matrix4.identity()
..setEntry(3, 2, 0.002)
..rotateY(pi*_rotateFactor),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
child: Container(
height: 150,
width: 150,
color: Colors.white,
child:Center(child: Image.asset(item.imageUrl)),
),
),
));
else
return Text('Errors');
【讨论】:
以上是关于条件满足后如何让卡片自动旋转?的主要内容,如果未能解决你的问题,请参考以下文章