Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter SearchDelegate,如何从buildResults打开/启动无状态小部件?_Flutter_Dart_Search - Fatal编程技术网

Flutter SearchDelegate,如何从buildResults打开/启动无状态小部件?

Flutter SearchDelegate,如何从buildResults打开/启动无状态小部件?,flutter,dart,search,Flutter,Dart,Search,我是编程新手。我在YT和博客上看过很多关于SearchDelegate的视频,但我不知道如何进入buildResult,因为它会打开现有的无状态小部件 这是我现在的SearchDelegate: 类搜索扩展了SearchDelegate{ 最终所有搜索=[ “座头鲸”, “长须鲸”, “蓝鲸”, ]; @凌驾 列出buildActions(BuildContext上下文){ 返回[ 图标按钮( 图标:图标(图标。清除), 已按下:(){ query=“”; }) ]; } @凌驾 小部件bui

我是编程新手。我在YT和博客上看过很多关于SearchDelegate的视频,但我不知道如何进入buildResult,因为它会打开现有的无状态小部件

这是我现在的SearchDelegate:

类搜索扩展了SearchDelegate{
最终所有搜索=[
“座头鲸”,
“长须鲸”,
“蓝鲸”,
];
@凌驾
列出buildActions(BuildContext上下文){
返回[
图标按钮(
图标:图标(图标。清除),
已按下:(){
query=“”;
})
];
}
@凌驾
小部件buildLeading(BuildContext上下文){
返回图标按钮(
图标:图标(图标。箭头返回),
已按下:(){
关闭(上下文,空);
});
}
@凌驾
小部件构建结果(构建上下文){
返回容器(
颜色:颜色,红色,
儿童:中心(
子项:文本(查询),
),
);
}
@凌驾
小部件构建建议(构建上下文){
final suggestionList=query.isEmpty
?所有搜索
:allSearch.where((p)=>p.contains(query)).toList();
返回ListView.builder(
itemBuilder:(上下文,索引)=>ListTile(
onTap:(){
展示结果(背景);
},
前导:图标(图标。搜索四舍五入),
标题:RichText(
text:TextSpan(
text:suggestionList[index]。子字符串(0,query.length),
风格:
TextStyle(颜色:Colors.black,fontwweight:fontwweight.bold),
儿童:[
TextSpan(
text:suggestionList[index]。子字符串(query.length),
样式:TextStyle(颜色:Colors.grey))
])),
),
itemCount:suggestionList.length,
);