我的问题是当我构建我的应用程序的 apk 时,按钮没有出现,你知道为什么吗?我留下的代码是开始屏幕。我无法测试它,因为我无法切换到其他屏幕,但是在 android studio 中使用模拟器时我没有任何问题。
class _mainmenuState extends State<mainmenu>{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(backgroundColor: Colors. red ,title: Text("Main Menu"),titleTextStyle: TextStyle(fontFamily: 'Helvetica Neue',fontSize: 20)
),
body: Stack(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Positioned(top: 0, left: 0, child: button1()),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Positioned(top: 0, left: 0, child: button2()),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Positioned(top: 0, left: 0, child: button3()),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Positioned(top: 0, left: 0, child: button4()),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Positioned(top: 0, left: 0, child: button5()),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Positioned(top: 0, left: 0, child: button6()),
],
),
],
)
);
}
}
按钮的结构是相同的,所以我发送一个:
[class button1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Align(
alignment: AlignmentDirectional(-0.95, -0.66),
child: ElevatedButton(
child: const Text('LEGS',
style: TextStyle(height: 1, fontSize: 14)
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => legsscreen()),
);
},
style: ElevatedButton.styleFrom(
minimumSize: Size(140.0, 47.0),
shape: RoundedRectangleBorder( borderRadius: BorderRadius.only(topLeft: Radius.zero, topRight: Radius.circular(30), bottomLeft: Radius.zero, bottomRight: Radius.circular(30) ) ),
primary: Colors.red,
),
),
);
}
}][1]