flutter - 在颤动的'FocusNode'中,脚手架的底部不起作用
问题描述
我在脚手架的底部有一个文本字段,并且想要在不关闭窗口的情况下进行计数输入。
为此,在接受输入后,我试图再次关注文本字段,但这种方法不起作用
让我解释一下下面的代码:
bottomSheet: BottomSheet(
onClosing: () {
},
builder: (context){
return Container(
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.black)
),
padding: const EdgeInsets.all(10),
child: (widget.state == true)? Row(children: [
Container(
width: 160,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(141, 148, 251, .5),
blurRadius: 10,
offset: Offset(0, 5))
]
),
child: TextFormField(
controller: _r,
textInputAction: TextInputAction.send,
focusNode: _node,
autofocus: true,
decoration: InputDecoration(
fillColor: Colors.deepPurple,
prefixIcon: Icon(Icons.person, color: Colors.grey,),
hintText: "R",
errorText: validate(_r.text),
hintStyle: TextStyle(
color: Colors.grey,
)
),
style: TextStyle(color:Colors.deepOrange),
keyboardType: TextInputType.number,
onFieldSubmitted: (value) {
setState(() {
val=true;
if(value != ""){
_addProduct(value);
}
});
FocusScope.of(context).requestFocus(_node); //This line is not working
},
),
),
Container(
height: 40,
padding: EdgeInsets.only(left:18),
child: RaisedButton(
color: Theme.of(context).accentColor,
onPressed: () {
print(_r.text);
setState(() {
val=true;
if(_r.text != ""){
_addProduct(_r.text);
}
FocusScope.of(context).requestFocus(_node); //This line is not working
});
},
child: Row(children: [
Icon(Icons.local_parking, color: Colors.white,),
Text('P', style: TextStyle(color: Colors.white),),
],)
),
),
Container(
height: 40,
padding: EdgeInsets.only(left:18),
child: RaisedButton(
color: Theme.of(context).accentColor,
onPressed: () {
_node.requestFocus(); //This line is not working
});
},
child: Row(children: [
Icon(Icons.delete, color: Colors.white,),
Text('Edit', style: TextStyle(color: Colors.white),),
],)
)
),
],)
);
})
这是我的脚手架底页的代码。我只是在底部表中输入并在脚手架的正文中显示我希望这两个部分分开,所以我使用正文,底部表但是当我在正文中显示我的列表时,底部表中的文本字段的焦点消失了,只有当我点击时才能聚焦在文本字段上
由于在文本字段中输入的元素,正文不断更新,因此底部表上的控件丢失
主要问题: “我只想继续在底页中输入并在正文中显示它,同时保持键盘连续打开”
请帮我解决这个问题
解决方案
推荐阅读
- cpython - Thread.join() 返回后 LWP 是否仍应运行?
- wpf - 如何遍历 DataGrid 以重新分配单元格文本
- elasticsearch - 如何在 ver_6.2.4 上的 Elasticsearch 中搜索具有相同父 ID 的子文档?
- c# - Asp.Net Core 未找到 DefaultChallengeScheme
- node.js - 未经用户同意向 Web 应用程序发送推送通知
- python - 在 python 中创建 CSV 文件时出现问题
- python - Statsmodels - 使用经过训练的 arima 模型通过显式提供要使用的 endog 值来进行手动点预测
- batch-file - 复制文件已存在并忽略源文件夹结构
- python-2.7 - Caffe2 没有检测到 GPU
- yocto - recipe 还产生需要打包的 -native 输出