flutter - 使用 mainAxisAlignment.spaceBetween 后减少列小部件中的一些空格
问题描述
我试图分隔我的小部件,它与我的列小部件下的 mainAxisAlignment.spaceBetween 一起使用,但我想让一些小部件彼此更接近。我如何减少一些特定假发之间的空间......下面是我的颤振代码
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(' '),
const Padding(
padding: EdgeInsets.only(left: 35.0),
child: Text(
'Cape Coast',
style: TextStyle(
fontSize: 40,
fontFamily: 'Dongle',
fontWeight: FontWeight.w700,
),
),
),
IconButton(
onPressed: () {
debugPrint('Search pressed');
},
icon: const FaIcon(FontAwesomeIcons.locationArrow),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text(
'Today, ',
style: TextStyle(
fontFamily: 'Dongle',
fontSize: 35,
fontWeight: FontWeight.w100),
),
Text(
'22:07',
style: TextStyle(
fontFamily: 'Dongle',
fontSize: 35,
fontWeight: FontWeight.w100),
),
],
),
解决方案
如果要添加自定义空间,那么最好的方法是使用 SizedBox()。您仍然可以使用 spacebetween,但您可以在两者之间添加 sizebox 并添加高度。现在你会说它不会响应,所以你可以使用宽度MediaQuery.of(context).size.height / Number which you want
(这个数字会增加和减少高度。
所以是这样的:
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(' '),
const Padding(
padding: EdgeInsets.only(left: 35.0),
child: Text(
'Cape Coast',
style: TextStyle(
fontSize: 40,
fontFamily: 'Dongle',
fontWeight: FontWeight.w700,
),
),
),
IconButton(
onPressed: () {
debugPrint('Search pressed');
},
icon: const FaIcon(FontAwesomeIcons.locationArrow),
),
],
),
SizedBox(
height: 30
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: const [
Text(
'Today, ',
style: TextStyle(
fontFamily: 'Dongle',
fontSize: 35,
fontWeight: FontWeight.w100),
),
Text(
'22:07',
style: TextStyle(
fontFamily: 'Dongle',
fontSize: 35,
fontWeight: FontWeight.w100),
),
],
),
推荐阅读
- android - 内存泄漏检测和循环
- reactjs - 反应本机选项卡导航屏幕标题未显示
- file - 是否可以查看存储的文件由什么序列的 1 和 0 组成?
- python - 使字典列表中的字典长度相等
- excel - 如何将这些硬编码的单元格引用更改为动态引用?
- node.js - 错误:运行 npm install pg 后找不到模块“pg”
- spring-boot - Pivotal Cloud Foundry Plus MySql DB
- java - 在 Firebase Firestore onCompletelistener 获取要列出的数据之前,CreateView 方法上的自定义对话框返回
- ios - 用 UILabel 的子类覆盖 UIButton 中的 titleLabel
- android - 为多个 sdk 版本编译