setMockDecodedMessageHandler<T> method
void
setMockDecodedMessageHandler<T>(
- BasicMessageChannel<
T> channel, - Future<
T> handler(- T? message
Intercepts messages sent on channel, decoding them with the channel's
codec before handing them to handler.
Mirrors TestDefaultBinaryMessenger.setMockDecodedMessageHandler.
Implementation
void setMockDecodedMessageHandler<T>(
BasicMessageChannel<T> channel,
Future<T> Function(T? message)? handler,
) {
if (handler == null) {
_setMockMessageHandler(channel.name, null);
return;
}
_setMockMessageHandler(channel.name, (ByteData? message) async {
return channel.codec
.encodeMessage(await handler(channel.codec.decodeMessage(message)));
});
}