Flutter TypeAheadField重建两次抽头颤振
我在Flutter TypeAheadField重建两次抽头颤振,flutter,typeahead,Flutter,Typeahead,我在Build()方法上有这个小部件 Widget\u buildIngredientsAutocompleteTextField(){ 打印(“检查是否重建”); 返回类型头字段( HidesSuggestionSonKeyboardHide:正确, hideOnEmpty:是的, hideOnError:对, KeepSuggestionSuggestionSelected:false, KeepSuggestionOnLoading:false, textFieldConfiguratio
Build()
方法上有这个小部件
Widget\u buildIngredientsAutocompleteTextField(){
打印(“检查是否重建”);
返回类型头字段(
HidesSuggestionSonKeyboardHide:正确,
hideOnEmpty:是的,
hideOnError:对,
KeepSuggestionSuggestionSelected:false,
KeepSuggestionOnLoading:false,
textFieldConfiguration:textFieldConfiguration(
focusNode:searchFocus,
控制器:搜索控制器,
textAlign:textAlign.center,
样式:TextStyle(字体大小:20),
装饰:输入装饰(
是的,
图标:图标(
Icons.search,
尺码:30,
),
hintText:“提示这个”,
),
),
suggestionsCallback:(模式)异步{
打印(“支票1”);
返回等待获得建议(模式);
},
条目生成器:(上下文,建议){。。。
onSuggestionSelected:(建议){
设置状态(){
一些代码。。。。
});
},
);
并为键盘添加了Listner(不确定这是否是原因n:
@覆盖
void initState(){
super.initState();
KeyboardVisibilityNotification().addNewListener(
onHide:(){
searchFocus.unfocus();
searchController.text=“”;
},
);...
每次我点击这个文本字段,它就会构建这个小部件两次,打开键盘,关闭它,然后重新打开它
原因可能是什么
这是调试控制台输出:
I/flutter ( 2081): Check if rebuild
W/IInputConnectionWrapper( 2081): beginBatchEdit on inactive InputConnection
W/IInputConnectionWrapper( 2081): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper( 2081): getTextAfterCursor on inactive InputConnection
W/IInputConnectionWrapper( 2081): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper( 2081): endBatchEdit on inactive InputConnection
I/flutter ( 2081): Check if rebuild