Now I am using SearchDelegate in flutter 2.0.1, this is my buildSuggestions code:
Widget buildSuggestionComponent(List<ChannelSuggestion> suggestions, BuildContext context) { return ListView.builder( itemCount: suggestions.length, itemBuilder: (context, index) { return ListTile( title: Text('${suggestions[index].name}'), onTap: () async { query = '${suggestions[index].name}'; }, ); }, ); } when select the recommand text, I want to automatically trigger search event so I do not need to click search button. this is my search code:
@override Widget buildResults(BuildContext context) { var channelRequest = new ChannelRequest(pageNum: 1, pageSize: 10, name: query); return buildResultImpl(channelRequest); } Widget buildResultImpl(ChannelRequest channelRequest) { return FutureBuilder( future: ChannelAction.searchChannel(channelRequest), builder: (context, AsyncSnapshot snapshot) { if (snapshot.hasData) { List<Channel> channels = snapshot.data; return buildResultsComponent(channels, context); } else { return Text(""); } return Center(child: CircularProgressIndicator()); }); } what should I do to implement it? I have tried invoke buildResults function in buildSuggestionComponent but it seems not work.
没有评论:
发表评论