public final class StringCodec extends Object implements MessageCodec<String>
MessageCodec using UTF-8 encoded String messages.
This codec is guaranteed to be compatible with the corresponding StringCodec on the Dart side. These parts of the Flutter SDK are evolved synchronously.
| Modifier and Type | Field and Description |
|---|---|
static StringCodec |
INSTANCE |
| Modifier and Type | Method and Description |
|---|---|
String |
decodeMessage(ByteBuffer message)
Decodes the specified message from binary.
|
ByteBuffer |
encodeMessage(String message)
Encodes the specified message into binary.
|
public static final StringCodec INSTANCE
public ByteBuffer encodeMessage(String message)
MessageCodecencodeMessage in interface MessageCodec<String>message - the T message, possibly null.public String decodeMessage(ByteBuffer message)
MessageCodecWarning: The ByteBuffer is "direct" and it won't be valid beyond this call. Storing
the ByteBuffer and using it later and will lead to a java.nio.BufferUnderflowException.
If you want to retain the data you'll need to copy it.
decodeMessage in interface MessageCodec<String>message - the ByteBuffer message, possibly null.