【发布时间】:2021-01-08 05:46:07
【问题描述】:
我想实现这样的布局。
在我专注于输入之前,它工作正常。
我想知道如何以正确的方式做到这一点......这是我到目前为止已经尝试过的:
- 在
SingleChildScrollView内包装表单(Spacer小部件导致错误)。 - 使用
CustomScrollView,(Spacer小部件导致错误)。 - 将
CustomScrollView或SingleChildScrollView包裹在SizedBox内受设备高度的限制(导致某些元素在较小的设备上仅部分可见)。 - 按照答案from this question(不起作用)。
有什么线索吗?这是我的代码:
class CreateFieldReportPage extends GetView<CreateFieldReportController> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
onTap: controller.focusScope.unfocus,
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 30),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
PageHeader(
helper: 'fieldReport.create.helper'.tr,
title: 'fieldReport.create'.tr,
),
Spacer(),
FieldReportForm(),
PageNavigator(
onPressedPrimaryButton: () {
Get.toNamed(Routes.EVENT_CREATE_ADD_USER);
},
),
],
),
),
),
),
);
}
}
【问题讨论】:
-
SingleChildScrollView 应该在顶部,你添加在顶部了吗,如果不行,可以通过删除 SafeArea 来尝试
-
我做了,还是不能在标题和表格之间加空格
-
尝试删除
spacer,而不是在Column中添加mainAxisAlignment,并尝试使用spaceBetween提供间距。
标签: flutter