public final class JSONMethodCodec extends Object implements MethodCodec
MethodCodec using UTF-8 encoded JSON method calls and result envelopes.
This codec is guaranteed to be compatible with the corresponding JSONMethodCodec on the Dart side. These parts of the Flutter SDK are evolved synchronously.
Values supported as methods arguments and result payloads are those supported by
JSONMessageCodec.
| Modifier and Type | Field and Description |
|---|---|
static JSONMethodCodec |
INSTANCE |
| Modifier and Type | Method and Description |
|---|---|
Object |
decodeEnvelope(ByteBuffer envelope)
Decodes a result envelope from binary.
|
MethodCall |
decodeMethodCall(ByteBuffer message)
Decodes a message call from binary.
|
ByteBuffer |
encodeErrorEnvelope(String errorCode,
String errorMessage,
Object errorDetails)
Encodes an error result into a binary envelope message.
|
ByteBuffer |
encodeMethodCall(MethodCall methodCall)
Encodes a message call into binary.
|
ByteBuffer |
encodeSuccessEnvelope(Object result)
Encodes a successful result into a binary envelope message.
|
public static final JSONMethodCodec INSTANCE
public ByteBuffer encodeMethodCall(MethodCall methodCall)
MethodCodecencodeMethodCall in interface MethodCodecmethodCall - a MethodCall.ByteBuffer containing the encoding between position 0 and
the current position.public MethodCall decodeMethodCall(ByteBuffer message)
MethodCodecdecodeMethodCall in interface MethodCodecmessage - the binary encoding of the method call as a ByteBuffer.MethodCall representation of the bytes between the given buffer's current
position and its limit.public ByteBuffer encodeSuccessEnvelope(Object result)
MethodCodecencodeSuccessEnvelope in interface MethodCodecresult - The result value, possibly null.ByteBuffer containing the encoding between position 0 and
the current position.public ByteBuffer encodeErrorEnvelope(String errorCode, String errorMessage, Object errorDetails)
MethodCodecencodeErrorEnvelope in interface MethodCodecerrorCode - An error code String.errorMessage - An error message String, possibly null.errorDetails - Error details, possibly null.ByteBuffer containing the encoding between position 0 and
the current position.public Object decodeEnvelope(ByteBuffer envelope)
MethodCodecdecodeEnvelope in interface MethodCodecenvelope - the binary encoding of a result envelope as a ByteBuffer.