【发布时间】:2020-11-22 02:14:40
【问题描述】:
我想实现一个布局,其中只有主按钮小部件将始终保留在脚手架的底部。其他小部件将放在SingleChildScrollView -> Column。
但当TextField 或TextFormField 获得焦点时,键盘应该将全屏推到布局底部,以便按钮可见。
使用 SingleChildScrollView 只会将TextField 或TextFormField 保留在键盘上方,而不是按钮。
我的代码:
body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
height: screenHeight(context) - kToolbarHeight - 24,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
PlaceHolder(),
SizedBox(height: 20.0),
Text('Select Time'),
SizedBox(height: 10.0),
PlaceHolder(),
SizedBox(height: 20.0),
PlaceHolder(),
SizedBox(height: 20.0),
// InputField is a TextFormField
InputField(
controller: _dataController,
labelText: 'Enter Data',
fieldFocusNode: _dataFocusNode,
textInputType: TextInputType.text,
),
SizedBox(height: 20.0),
CheckboxListTile(),
SizedBox(height: 20.0),
PrimaryButton(
buttonText: 'Save',
onPressed: () {},
),
SizedBox(height: 20.0),
],
),
),
),
这是两个屏幕布局。您可以忽略除TextFormField 和Main Button 之外的所有其他小部件。
屏幕一:无键盘(TextField 或 TextFormField 未聚焦)
屏幕二:使用键盘(TextField 或 TextFormField 聚焦)
【问题讨论】:
-
您可以在问题中包含您的代码吗?另外,请尽量减少图片。
-
好的。添加...
标签: flutter