decodeMessage method Null safety

  1. @override
dynamic decodeMessage(
  1. ByteData? message
)
override

Decodes the specified message from binary.

Returns null if the message is null.

Implementation

@override
dynamic decodeMessage(ByteData? message) {
  if (message == null) {
    return null;
  }
  final ReadBuffer buffer = ReadBuffer(message);
  final Object? result = readValue(buffer);
  if (buffer.hasRemaining) {
    throw const FormatException('Message corrupted');
  }
  return result;
}