我试图制作一个带有固定按钮和两个动画按钮的Flutter动画圆形晶圆厂菜单。 onPressed
方法仅适用于固定按钮,不适用于固定按钮。我用iconbutton尝试了很多东西,但结果始终相同。
这是我的代码的一部分,用于解释我制作的ui。它只有三个按钮,一个固定按钮和两个动画按钮。动画可以正常播放,但是onPressed
无法正常播放。
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(),
body: Container(
child: Stack(
children: <Widget>[
Positioned(
right: 30,
bottom: 30,
child: Stack(
children: <Widget>[
Transform.translate(
offset: Offset.fromDirection(getRadiansFromDegree(270),
degOneTranslationAnimation.value * 100),
child: Transform(
transform: Matrix4.rotationZ(
getRadiansFromDegree(rotationAnimation.value))
..scale(degOneTranslationAnimation.value),
alignment: Alignment.center,
child:Container(
decoration: BoxDecoration(color:Colors.green,shape: BoxShape.circle),
child:FloatingActionButton(
child: Icon(
Icons.stay_primary_portrait,
color: Colors.deepPurpleAccent,
),
backgroundColor: Colors.white,
onPressed:(){something;
print("hi");},
),
),
),
),
Transform.translate(
offset: Offset.fromDirection(getRadiansFromDegree(180),
degThreeTranslationAnimation.value * 100),
child: Transform(
transform: Matrix4.rotationZ(
getRadiansFromDegree(rotationAnimation.value))
..scale(degThreeTranslationAnimation.value),
alignment: Alignment.center,
child:FloatingActionButton(
child: Icon(
Icons.stay_primary_portrait,
color: Colors.deepPurpleAccent,
),
backgroundColor: Colors.white,
onPressed:(){
print("hi");},
),,
),
),
Transform(
transform: Matrix4.rotationZ(
getRadiansFromDegree(rotationAnimation.value)),
alignment: Alignment.center,
child:Container(
decoration: BoxDecoration(color:Colors.red,shape: BoxShape.circle),
child:IconButton(
color: Colors.red,
icon: Icon(
Icons.menu,
color: Colors.white,
),
onPressed: () {
if (animationController.isCompleted) {
animationController.reverse();
} else {
animationController.forward();
}
print('ok');
},
),
),
)
],
))
],
),
));
}
void something(){
print("hello");
}
}