encodeMessage method Null safety

  1. @override
ByteData? encodeMessage(
  1. String? message
)
override

Encodes the specified message in binary.

Returns null if the message is null.

Implementation

@override
ByteData? encodeMessage(String? message) {
  if (message == null) {
    return null;
  }
  final Uint8List encoded = utf8.encoder.convert(message);
  return encoded.buffer.asByteData();
}