如果父容器正在改变高度,则颤振键盘不会聚焦

问题描述

我有一个小部件,用户应该能够在其中添加注释。如果 container 内部的 textField 未处于活动状态,则此 container 应采用所需的高度。但如果用户正在编辑,child: Container( padding: EdgeInsets.only( top: 21.scaled,left: 21.scaled,right: 21.scaled,bottom: 28.scaled,),height: widget.articleState.isEditingNotes ? 223.scaled : null,// <- important line child: Column( crossAxisAlignment: CrossAxisAlignment.start,children: [ Text( 'Notiz vom ${_getLastUpdatedAsText()}',style: alternativeTextSmall.copyWith(color: darkGray),SizedBox(height: 5.scaled),TextField( controller: _controller,focusNode: widget.articleState.articleNotesFocusNode,maxLines: null,style: h3.copyWith(fontSize: 18.scaled),decoration: null,onChanged: widget.articleState.updateNoteText,],) 应将其高度更改为 233。

这就是我试图完成这项工作的方式:

focus

我正在根据用户是否正在编辑文本字段来更改高度。

但这不能正常工作。如果我给 Container 一个固定的高度,这就是它的行为:

TextField working correctly

但是如果我根据 {{1}} 改变高度,它的行为是这样的:

not working as expected

如您所见,我必须单击两次。此外,即使在我单击两次并且 textField 处于焦点之后,光标也不可见,直到我实际键入内容...

我不知道为什么会发生这种情况。有谁可以帮我离开这里吗?如果您需要更多信息,请告诉我!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)