class MessageSearchPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: MessageSearchBloc(
child: MessageSearchListView(
filters: Filter.in_('members', [StreamChat.of(context).user!.id],),
messageQuery: 'your query here',
limit: 20,
),
),
);
}
}
This is documentation for
Stream Chat Flutter SDK v3, which is nolonger actively maintained. For up-to-date documentation, see the latest version (v8).
MessageSearchListView
A Widget To Search For Messages Across Channels
Find the pub.dev documentation here
Background
Users in Stream Chat can have several channels and it can get hard to remember which channel has the
message they are searching for. As such, there needs to be a way to search for a message across multiple
channels. This is where MessageSearchListView
comes in.
Basic Example
While the MessageListView is tied to a certain StreamChannel
, a MessageSearchListView
is not.
Customize The Result Tiles
You can use your own widget for the result items using the itemBuilder
parameter.
MessageSearchListView(
// ...
itemBuilder: (context, response) {
return Text(response.message.text);
},
),
Show Result Count
You show the number of results via the showResultCount
parameter.
MessageSearchListView(
// ...
showResultCount: true,
),