flutter - 如何将图标与最顶部的文本对齐
问题描述
考虑这个用户界面:
代码:
Widget shopHeader(var shopName, var shopAddress){
return Container(
height: 200,
margin: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
padding: const EdgeInsets.all(1.0),
child: const Icon(Icons.home, color: Colors.black),
decoration: const BoxDecoration(
color: Colors.grey, // border color
shape: BoxShape.circle,
),
),
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
shopName,
style: TextStyle(fontSize: 17),
),
Text(
shopAddress,
style: TextStyle(fontSize: 14, color:Colors.black38),
),
Padding(
padding: EdgeInsets.only(left:0.0, right:0.0, top:20.0, bottom:0.0),
child: SizedBox(
width: 150,
child: ElevatedButton(
child: Text('Chat'),
onPressed: () {},
))
)
],
),
],
),
);
}
左边的图标太低了。如何设置它使其与“Awesome Shop”文本对齐?
解决方案
在最上面的 Row 小部件上,使用 CrossAxisAllignment 属性来 CrossAxisAllignment.start。
推荐阅读
- c# - Unity TileMaps:如何返回占据特定 Vector3 位置的图块的图层名称、标签或其他标识信息?
- mongodb - Spring Boot MongoDB findTop5 返回空数组
- java - 如何将文件从 s3 存储桶复制到 ec2 主文件夹
- r - R - 在文件中打印列表并恢复列表
- angularjs - AngularJS ng-options 按数组值过滤
- css - html-pdf:如何确保图像不跨越分页符
- mysql - 使用 mysql.connection 根据其他两列中的值返回行 ID
- javascript - 为什么我的可排序功能在 Rails 中不起作用?
- python - 有什么方法可以知道正在运行的 Windows 版本是什么?
- angularjs - Angularjs使用组件封装输入框