I am building a flutter web app, in which I have a Stack. In the Stack I have a Row with some buttons (along with other things). I made a seperate widget for the buttons. this is the code for that:
class UserPageButton extends StatelessWidget {
final double width;
final String text;
final onPressed;
UserPageButton(this.width, this.text, this.onPressed);
@override
Widget build(BuildContext context) {
return Container(
width: width,
height: MediaQuery.of(context).size.height / 35,
child: ElevatedButton(
onPressed: onPressed,
style: ButtonStyle(
shape: MaterialStateProperty.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100))),
backgroundColor: MaterialStateProperty.resolveWith(
(states) => CustomColours.lightBlue)),
child: FittedBox(
fit: BoxFit.fill,
child: Text(
text,
style: TextStyle(
color: CustomColours.darkBlue, fontFamily: 'FuturaBold'),
)),
),
);
}
}
I have it in the Stack like this:
Transform.translate(
offset: Offset(width / 8, height / 6),
child: Container(
width: width / 4,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
UserPageButton(width / 100 * 8, 'User Info',
() {
print('click');
}),
UserPageButton(
width / 100 * 8, 'Match History', () {
print('click');
}),
UserPageButton(
width / 100 * 8, 'Invited People', () {
print('click');
}),
],
)),
),
However, for some reason I can't press the buttons. What am I doing wrong? Thanks
Aucun commentaire:
Enregistrer un commentaire