Package io.flutter.plugin.common

## Class StandardMethodCodec

- java.lang.Object
- - io.flutter.plugin.common.StandardMethodCodec

- All Implemented Interfaces:
    `MethodCodec`

      public final class StandardMethodCodec
      extends Object
      implements MethodCodec

  A `MethodCodec` using the Flutter standard binary encoding.

  This codec is guaranteed to be compatible with the corresponding StandardMethodCodec on the Dart side. These parts of the Flutter SDK are evolved synchronously.

  Values supported as method arguments and result payloads are those supported by `StandardMessageCodec`.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static StandardMethodCodec` | `INSTANCE` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `StandardMethodCodec​(StandardMessageCodec messageCodec)` | Creates a new method codec based on the specified message codec.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Object` | `decodeEnvelope​(ByteBuffer envelope)` | Decodes a result envelope from binary.
    `MethodCall` | `decodeMethodCall​(ByteBuffer methodCall)` | Decodes a message call from binary.
    `ByteBuffer` | `encodeErrorEnvelope​(String errorCode, String errorMessage, Object errorDetails)` | Encodes an error result into a binary envelope message.
    `ByteBuffer` | `encodeErrorEnvelopeWithStacktrace​(String errorCode, String errorMessage, Object errorDetails, String errorStacktrace)` | Encodes an error result into a binary envelope message with the native stacktrace.
    `ByteBuffer` | `encodeMethodCall​(MethodCall methodCall)` | Encodes a message call into binary.
    `ByteBuffer` | `encodeSuccessEnvelope​(Object result)` | Encodes a successful result into a binary envelope message.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INSTANCE

          public static final StandardMethodCodec INSTANCE

  - ### Constructor Detail

    - #### StandardMethodCodec

          public StandardMethodCodec​(StandardMessageCodec messageCodec)

      Creates a new method codec based on the specified message codec.

  - ### Method Detail

    - #### encodeMethodCall

          public ByteBuffer encodeMethodCall​(MethodCall methodCall)

      Description copied from interface: `MethodCodec`
      Encodes a message call into binary.
      Specified by:
        `encodeMethodCall` in interface `MethodCodec`
      Parameters:
        `methodCall` - a `MethodCall`.
      Returns:
        a `ByteBuffer` containing the encoding between position 0 and the current position.

    - #### decodeMethodCall

          public MethodCall decodeMethodCall​(ByteBuffer methodCall)

      Description copied from interface: `MethodCodec`
      Decodes a message call from binary.
      Specified by:
        `decodeMethodCall` in interface `MethodCodec`
      Parameters:
        `methodCall` - the binary encoding of the method call as a `ByteBuffer`.
      Returns:
        a `MethodCall` representation of the bytes between the given buffer's current position and its limit.

    - #### encodeSuccessEnvelope

          public ByteBuffer encodeSuccessEnvelope​(Object result)

      Description copied from interface: `MethodCodec`
      Encodes a successful result into a binary envelope message.
      Specified by:
        `encodeSuccessEnvelope` in interface `MethodCodec`
      Parameters:
        `result` - The result value, possibly null.
      Returns:
        a `ByteBuffer` containing the encoding between position 0 and the current position.

    - #### encodeErrorEnvelope

          public ByteBuffer encodeErrorEnvelope​(String errorCode,
                                                String errorMessage,
                                                Object errorDetails)

      Description copied from interface: `MethodCodec`
      Encodes an error result into a binary envelope message.
      Specified by:
        `encodeErrorEnvelope` in interface `MethodCodec`
      Parameters:
        `errorCode` - An error code String.
        `errorMessage` - An error message String, possibly null.
        `errorDetails` - Error details, possibly null. Consider supporting `Throwable` in your codec. This is the most common value passed to this field.
      Returns:
        a `ByteBuffer` containing the encoding between position 0 and the current position.

    - #### encodeErrorEnvelopeWithStacktrace

          public ByteBuffer encodeErrorEnvelopeWithStacktrace​(String errorCode,
                                                              String errorMessage,
                                                              Object errorDetails,
                                                              String errorStacktrace)

      Description copied from interface: `MethodCodec`
      Encodes an error result into a binary envelope message with the native stacktrace.
      Specified by:
        `encodeErrorEnvelopeWithStacktrace` in interface `MethodCodec`
      Parameters:
        `errorCode` - An error code String.
        `errorMessage` - An error message String, possibly null.
        `errorDetails` - Error details, possibly null. Consider supporting `Throwable` in your codec. This is the most common value passed to this field.
        `errorStacktrace` - Platform stacktrace for the error. possibly null.
      Returns:
        a `ByteBuffer` containing the encoding between position 0 and the current position.

    - #### decodeEnvelope

          public Object decodeEnvelope​(ByteBuffer envelope)

      Description copied from interface: `MethodCodec`
      Decodes a result envelope from binary.
      Specified by:
        `decodeEnvelope` in interface `MethodCodec`
      Parameters:
        `envelope` - the binary encoding of a result envelope as a `ByteBuffer`.
      Returns:
        the enveloped result Object.