flutter - 我如何将卡片水平和垂直居中,即在活动的中心
问题描述
嗨,我想将一张应该水平和垂直居中的卡片居中,我试图通过定位小部件来实现这一点,但无法这样做。
这是我的代码:
Positioned(
child:
Card(
shape: RoundedRectangleBorder(
borderRadius:BorderRadius.circular(30.0),
side: BorderSide(color: Color.fromRGBO(214, 0, 27, 1)),
),
child: Column(
children: <Widget>[
Container(
margin: EdgeInsets.only(top: 10),
child: Row(
children: <Widget>[
Container(
child: Text("hello@xyz.com",
style: TextStyle(
fontWeight: FontWeight.normal,
color: Colors.black,
fontSize: 16)),
)
],
))
],
),
),
),
解决方案
在您的小部件之前,请使用中心小部件。
Card(
child: Center(
child: YourWidgets()
))
推荐阅读
- machine-learning - RandomOverSampler 条件创建均等分布
- java - 如何在Java中编写正则表达式以删除匹配字符后字符串中的所有字符?
- mysql - 从 Nodejs 中的两个不同数据库连接表
- c# - 如果人员 XML 列表中存在具有特定姓名的人员
- sql - Oracle 12c JSON TABLE 解析错误处理
- html - flex 行反向中的元素对齐
- javascript - 如何从父组件 prop 访问子组件 prop
- python - 如何跳过两个文件中以#开头的行
- css - 为什么没有应用特定的 CSS 类?
- javascript - 需要限制表中字段的大小