flutter - 无法更改 SingChildScroll 视图中的列轴对齐方式
问题描述
我想在列内的小部件之间添加间距,而不对每个 SizedBox 进行硬编码并给它们一定的高度,我想直接在列上设置它但没有对齐选项起作用,我做错了什么?这是什么原因造成的?
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Submit Your Order'),
),
body: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(20.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, // doesnt work
children: [
InformationField(
label: 'Phone Number',
hintText: 'Type Your Phone Number',
),
InformationField(
label: 'Name',
hintText: 'Type Your Name',
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
InformationField(
label: 'Adress',
hintText: 'Neighborhood/City',
),
SizedBox(
height: 5.0,
),
RowInformationField()
],
),
],
),
),
),
),
);
}
解决方案
如果您正在使用SingleChildScrollView
,请不要指望mainAxisAlignment
工作。我建议您将其替换为CustomScrollView
以达到您想要的结果。
推荐阅读
- postgresql - 为什么 HikariCP 在 postgresql 中创建这么多空闲连接
- ruby - 以 JavaScript 方式在 Ruby 中分配对象
- python - 如何使用具有固定常量的 scipy 最小化
- wordpress - 在 wordpress 页面之间传递数据
- jquery - Select2 选择订单返回不同选项的值
- java - 为什么 .jar 可执行文件不会在 javafx (java) 中加载 Web 视图?
- arrays - Swift 将矩阵中的元素值更改为 3 个数组
- flask - 夸脱的通用 URL
- mysql - 在 JavaScript 中使用 MySQL
- python - 花括号内是否存在类似数据-python