class MyCustomEventHandler extends StreamChannelListEventHandler {
@override
void onConnectionRecovered(
Event event,
StreamChannelListController controller,
) {
// Write your own custom implementation here
}
}Channels Events
StreamChannelListEventHandler controls how the channel list responds to real-time Stream Chat events such as new messages, channel additions, and membership changes. Extend this class to customize which events trigger list updates and how those updates are applied. See the pub.dev documentation for the full API reference.
Background
A StreamChannelListEventHandler is a class that handles the events that are related to the channel list loaded by StreamChannelListController.
The StreamChannelListController automatically creates a StreamChannelListEventHandler internally and handles the events. In order to provide a custom
implementation of StreamChannelListEventHandler, you need to create a class that extends the StreamChannelListEventHandler class.
Basic Example
There are 2 ways to provide a custom implementation of StreamChannelListEventHandler:
- Create a class that extends the
StreamChannelListEventHandlerand pass it down to the controller.
Pass it down to the controller:
late final listController = StreamChannelListController(
client: StreamChat.of(context).client,
eventHandler: MyCustomEventHandler(),
);- Mix the
StreamChannelListEventHandlerinto your widget state.
class _ChannelListPageState extends State<ChannelListPage> {
late final _listController = StreamChannelListController(
client: StreamChat.of(context).client,
eventHandler: MyCustomEventHandler(),
);
}