gpt4 book ai didi

Flutter:非事件InputConnection上的getTextBeforeCursor

转载 作者:行者123 更新时间:2023-12-02 11:17:38 25 4
gpt4 key购买 nike

我正在尝试检索TextField标题内的用户输入,以便可以将其传递给名为 void _filterList(value)的函数。
但是,每次我输入一些文本时,都会出现以下错误:

W/IInputConnectionWrapper( 7715): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 7715): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 7715): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 7715): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 7715): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 7715): endBatchEdit on inactive InputConnection
这是我的代码:
List filteredlist = [];
List entries = [];
bool isSearching = false;

getCountries() async {
var response =
await Dio().get('https://restcountries.eu/rest/v2/regionalbloc/eu');
return response.data;
}

@override
void initState() {
getCountries().then((data) {
setState(() {
entries = filteredlist = data;
});
});
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: !isSearching
? Text('All EU Countries')
: TextField(
onChanged: (value) {
_filterList(value);
},
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
icon: Icon(Icons.search, color: Colors.white),
hintText: "Search Here",
hintStyle: TextStyle(color: Colors.white),
)),
actions: <Widget>[
isSearching
? IconButton(
icon: Icon(Icons.cancel),
onPressed: () {
setState(() {
this.isSearching = false;
filteredlist = entries;
});
},
)
: IconButton(
icon: Icon(Icons.search),
onPressed: () {
setState(() {
this.isSearching = true;
});
})
],
),
body: _buildList());
}
这是我的功能:
void _filterList(value) {
setState(() {
filteredlist = entries.where(
(entry) => entry['name'].toLoweCase().contains(value.toLowerCase()));
});
}
据我所知,键盘似乎有问题,但是我还没有弄清楚如何防止键盘损坏

最佳答案

已知问题,已跟踪here。即使这个sample code在android中也会发出警告。造成问题的原因尚未达成共识。

I did a little bit of digging. It looks like Android is generating these warnings because we are holding the InputConnection incorrectly in the Engine's TextInputPlugin. I haven't really figured out what we're doing wrong, though.


source

关于Flutter:非事件InputConnection上的getTextBeforeCursor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63042413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com