gpt4 book ai didi

android - 如何在 flutter 中对齐卡片 View 中心

转载 作者:IT王子 更新时间:2023-10-29 07:09:44 26 4
gpt4 key购买 nike

我在flutter中设计了这个布局。我想将卡片移到中心(水平和垂直)。卡片的宽度和高度应该是包装内容。

有人知道如何实现吗?

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)),
)
],
))
],
),
));
}
}

enter image description here

最佳答案

crossAxisAlignment的参数值改为CrossAxisAlignment.center,然后添加mainAxisAlignment: MainAxisAlignment.centermainAxisSize: MainAxisSize。分钟

关于android - 如何在 flutter 中对齐卡片 View 中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54059809/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com