Package io.flutter.plugin.common
Class StringCodec
- java.lang.Object
-
- io.flutter.plugin.common.StringCodec
-
- All Implemented Interfaces:
MessageCodec<String>
public final class StringCodec extends Object implements MessageCodec<String>
AMessageCodecusing 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.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCodecINSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringdecodeMessage(ByteBuffer message)Decodes the specified message from binary.ByteBufferencodeMessage(String message)Encodes the specified message into binary.
-
-
-
Field Detail
-
INSTANCE
public static final StringCodec INSTANCE
-
-
Method Detail
-
encodeMessage
@Nullable public ByteBuffer encodeMessage(@Nullable String message)
Description copied from interface:MessageCodecEncodes the specified message into binary.- Specified by:
encodeMessagein interfaceMessageCodec<String>- 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
@Nullable public String decodeMessage(@Nullable ByteBuffer message)
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<String>- 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.
-
-