Hello,
I'm trying to implement bloc with SearchDelegate.
Do you have any example?
Thanks
Hi @endigo can you please provide more details like a code sample of what you鈥檇 like to be able to accomplish?
Thanks for a response,
I have 1 screen, call a showSearch method.
class ScreenOne extends StatefulWidget {
...
}
class _ScreenOneState extends State<ScreenOne> {
@override
Widget build(BuildContext context) {
return Container(
child: RaisedButton(
child: Text('Show search'),
onPress: () async {
City selected = await showSearch<City>(context, delegate: new CityDelegate());
print(selected.name);
}
)
);
}
}
Here is SearchDelegate
class CitySearch extends SearchDelegate<City> {
final CityBloc _bloc = new CityBloc();
... other codes
...
... other codes
@override
Widget buildResults(BuildContext context) {
print(query);
// SearchDelegate has field 'query', changes in user input.
// Here I want to use bloc for search/filtering from datasource.
return StreamBuilder<UnmodifiableListView<City>>(
stream: _bloc.cities,
builder: (BuildContext context, AsyncSnapshot<UnmodifiableListView<City>> snapshot) {
return ListView();
},
}
...
}
There is no onChange method on SearchDelegate.
@endigo I think you should be able to do something like this.
Let me know if that helps.
Thank for your time. It's works.
Most helpful comment
@endigo I think you should be able to do something like this.
Let me know if that helps.