【发布时间】:2021-09-28 01:17:19
【问题描述】:
我在 SearchDelegate 中有这段代码
class CustomSearchDelegate extends SearchDelegate<String> {
@override
List<Widget> buildActions(BuildContext context) {
return [
IconButton(
icon: Icon(Icons.clear),
onPressed: (){
query = "";
},
)
];
}
@override
Widget buildLeading(BuildContext context) {
return IconButton(
icon: Icon(Icons.arrow_back),
onPressed: (){
close(context, "");
},
);
}
@override
Widget buildResults(BuildContext context) {
close(context, query );
return Container();
}
@override
Widget buildSuggestions(BuildContext context) {
return Container();
}
}
当我在调试模式下运行它时,它可以正常工作。但是当我在发布模式下运行时,确认搜索时,它不会返回调用搜索的页面,它只是返回容器,即使使用“关闭(上下文,查询);”在 buildResults 之前。
【问题讨论】: