搜索代表<String>键盘操作按钮按下问题



搜索键盘板操作(flutter中的SearchDelegate<>(。单击键盘中的搜索按钮时,它显示错误

我只是尝试通过搜索委托来调用搜索操作按钮。

class DataSearch extends SearchDelegate<String> {
  @override
  List<Widget>buildActions(BuildContext context) {
    return [
      Container(
        alignment: Alignment.topCenter,
        width: 1.0,
        color: Colors.grey,
        margin: const EdgeInsets.only(
            left: 8.0, top: 10.0, right: 0.0, bottom: 10.0),
      ),
      IconButton(
          icon: Icon(
            Icons.clear,
            size: 30,
          ),
          onPressed: () {
            query = "";
          }),
    ];
  }
  @override
  Widget buildLeading(BuildContext context) {
    return
      IconButton(
        icon: AnimatedIcon(
          icon: AnimatedIcons.menu_arrow,
          progress: transitionAnimation,
        ),
        onPressed: () {
          close(context, null);
        },
      );
  }
  @override
  Widget buildResults(BuildContext context) {}
  @override
  Widget buildSuggestions(BuildContext context) {
    return Container();
  }
}

它显示一个错误页面

@override 
Widget buildResults(BuildContext context){
return Container(
      //Do what you want to show in the result, when click keyboard action Search.
);
}

最新更新