Package io.flutter.plugin.common
Class BinaryCodec
java.lang.Object
io.flutter.plugin.common.BinaryCodec
- All Implemented Interfaces:
MessageCodec<ByteBuffer>
A
MessageCodec using unencoded binary messages, represented as ByteBuffers.
This codec is guaranteed to be compatible with the corresponding BinaryCodec on the Dart side. These parts of the Flutter SDK are evolved synchronously.
On the Dart side, messages are represented using ByteData.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BinaryCodecstatic final BinaryCodecA BinaryCodec that returns direct ByteBuffers from `decodeMessage` for better performance. -
Method Summary
Modifier and TypeMethodDescriptiondecodeMessage(ByteBuffer message) Decodes the specified message from binary.encodeMessage(ByteBuffer message) Encodes the specified message into binary.
-
Field Details
-
INSTANCE
-
INSTANCE_DIRECT
A BinaryCodec that returns direct ByteBuffers from `decodeMessage` for better performance.- See Also:
-
BinaryCodec(boolean)
-
-
Method Details
-
encodeMessage
Description copied from interface:MessageCodecEncodes the specified message into binary.- Specified by:
encodeMessagein interfaceMessageCodec<ByteBuffer>- Parameters:
message- the T message, possibly null.- Returns:
- a ByteBuffer containing the encoding between position 0 and the current position, or null, if message is null.
-
decodeMessage
Description copied from interface:MessageCodecDecodes the specified message from binary.Warning: 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.- Specified by:
decodeMessagein interfaceMessageCodec<ByteBuffer>- Parameters:
message- theByteBuffermessage, possibly null.- Returns:
- a T value representation of the bytes between the given buffer's current position and its limit, or null, if message is null.
-