[英]How to align card view center in flutter
I have designed this layout in the flutter. 我已经在颤振中设计了这种布局。 I want to move the card into the center (horizontally and vertically).
我想将卡移动到中心(水平和垂直)。 Card width and height should be wrap content.
卡的宽度和高度应为包装内容。
Does anyone know how to achieve this ? 有谁知道如何实现这一目标?
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
,然后添加mainAxisAlignment: MainAxisAlignment.center
和mainAxisSize: MainAxisSize.min
body: Center(child: Card(...
or 要么
body: Container(alignment: Alignment.center, child: Card(...
with Container
you can use different types of alignment
使用
Container
您可以使用不同类型的alignment
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.