【发布时间】:2023-03-22 18:13:01
【问题描述】:
我已经设计了这个布局。我想将卡片移动到中心(水平和垂直)。卡片的宽度和高度应该是换行内容。
有谁知道如何做到这一点?
class ContactUsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("CONTACT US"),
backgroundColor: Colors.redAccent,
),
body: Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Text("Need Help ?",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 22)),
),
Container(
margin: EdgeInsets.only(top: 10),
child: Text("Max MagiX,",
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black,
fontSize: 16)),
),
Container(
child: Text("San Francisco,",
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black,
fontSize: 16)),
),
Container(
child: Text("CA, USA",
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black,
fontSize: 16)),
),
Container(
margin: EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
Icon(Icons.phone),
Container(
margin: EdgeInsets.only(left: 2),
child: Text("+1 8002 8002 82",
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black,
fontSize: 16)),
)
],
)),
Container(
margin: EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
Icon(Icons.email),
Container(
margin: EdgeInsets.only(left: 2),
child: Text("hello@xyz.com",
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black,
fontSize: 16)),
)
],
))
],
),
));
}
}
【问题讨论】:
-
尝试将
crossAxisAlignment的参数改成CrossAxisAlignment.center,连同Andrey的回答。