I am using the following code in which I am unable to detect button click on subButtons. The click on main button works just fine as it displays and hides and subButtons. There are three sub-buttons behind the main button and they come out when main button is pressed. I got this code from : https://www.youtube.com/watch?v=S7KG4prI7A4 I never really understood animations in flutter but this was a good starting point. My knowledge in animation is limited to the to something basic such as Hero Widget.
Expanded(
child: Stack(
children: <Widget>[
ListView.builder ... // Listfview here
Positioned(
right: 23,
bottom: 23,
child: Stack(
alignment: Alignment.bottomRight,
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: CircularButton(
color: Provider.of<UserData>(context,listen: false).getPrimaryColor(),
width: 50,
height: 50,
icon: Icon(
Icons.note,
color: Colors.white,
),
onClick: (){
print('Noted clicked'); // *Can't Detect*
},
),
),
),
Transform.translate(
offset: Offset.fromDirection(getRadiansFromDegree(225),degTwoTranslationAnimation.value * 100),
child: Transform(
transform: Matrix4.rotationZ(getRadiansFromDegree(rotationAnimation.value))..scale(degTwoTranslationAnimation.value),
alignment: Alignment.center,
child: CircularButton(
color: Provider.of<UserData>(context,listen: false).getPrimaryColor(),
width: 50,
height: 50,
icon: Icon(
Icons.camera_alt,
color: Colors.white,
),
onClick: (){
print('Second button'); // *Can't Detect*
},
),
),
),
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: CircularButton(
color: Provider.of<UserData>(context,listen: false).getPrimaryColor(),
width: 50,
height: 50,
icon: Icon(
Icons.report_problem,
color: Colors.white,
),
onClick: (){
//TODO
print ('Three clicked'); // *Can't Detect*
},
),
),
),
Transform(
transform: Matrix4.rotationZ(getRadiansFromDegree(rotationAnimation.value)),
alignment: Alignment.center,
child: CircularButton(
color: Provider.of<UserData>(context,listen: false).getSecondryColor(),
width: 60,
height: 60,
icon: Icon(
Icons.menu,
color: Colors.white,
),
onClick: (){
print ('clicked'); // WORKS FINE
if (animationController.isCompleted) {
animationController.reverse();
} else {
animationController.forward();
}
},
),
)
],
)),
],
),
),
class CircularButton extends StatelessWidget {
final double width;
final double height;
final Color color;
final Icon icon;
final Function onClick;
CircularButton({this.color, this.width, this.height, this.icon, this.onClick});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(color: color,shape: BoxShape.circle),
width: width,
height: height,
child: IconButton(icon: icon,enableFeedback: true, onPressed: onClick),
);
}
}