Flutter 整体身体单视图
我想将主体包装在SingleChildScrollView小部件中,但由于某些原因,它无法工作。当我将容器包装在SingleChildScrollView小部件中时,一切都消失了。有解决办法吗Flutter 整体身体单视图,flutter,Flutter,我想将主体包装在SingleChildScrollView小部件中,但由于某些原因,它无法工作。当我将容器包装在SingleChildScrollView小部件中时,一切都消失了。有解决办法吗 Scaffold( body: Container( padding: const EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start
Scaffold(
body: Container(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Spacer(),
DisplayText(),
Spacer(),
Form(
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter your username',
),
textInputAction: TextInputAction.next,
),
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter your password',
),
),
],
),
),
.
.
.
.
],
),
),
);
您可以使用
列
包装整个布局,并使用展开的
小部件展开子项,然后添加SingleChildScrollView
。请删除Spacer
,如果您需要小部件之间的空间,请使用SizedBox
Scaffold(
body: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 10,),
DisplayText(),
SizedBox(height: 10,),
Form(
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter your username',
),
textInputAction: TextInputAction.next,
),
TextFormField(
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Enter your password',
),
),
],
),
),
],
),
),
),
),
],
),
);
你的主意很管用。但是我有一个问题,为什么不使用Spacer()?