Я попытался создать анимированное круглое потрясающее меню Flutter с фиксированной кнопкой и двумя анимированными кнопками. Метод onPressed
работает только с фиксированной кнопкой и не работает с фиксированной кнопкой. Я много чего пробовал с иконкой, но результат всегда один и тот же.
Это часть моего кода, объясняющая пользовательский интерфейс, который я сделал. У него всего три кнопки, одна фиксированная кнопка и две анимированные кнопки. Анимация работает правильно, но 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");
}
}