io.flutter.plugin.common

## Interface BinaryMessenger

- All Known Implementing Classes:
    DartExecutor, FlutterNativeView, FlutterView

      public interface BinaryMessenger

  Facility for communicating with Flutter using asynchronous message passing with binary messages. The Flutter Dart code should use BinaryMessages to participate.

  `BinaryMessenger` is expected to be utilized from a single thread throughout the duration of its existence. If created on the main thread, then all invocations should take place on the main thread. If created on a background thread, then all invocations should take place on that background thread.

  See Also:
    `, which supports message passing with Strings and semi-structured messages.`, `, which supports communication using asynchronous method invocation.`, `, which supports communication using event streams.`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `BinaryMessenger.BinaryMessageHandler` Handler for incoming binary messages from Flutter.
    `static interface` | `BinaryMessenger.BinaryReply` Binary message reply callback.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `send(String channel, ByteBuffer message)` Sends a binary message to the Flutter application.
    `void` | `send(String channel, ByteBuffer message, BinaryMessenger.BinaryReply callback)` Sends a binary message to the Flutter application, optionally expecting a reply.
    `void` | `setMessageHandler(String channel, BinaryMessenger.BinaryMessageHandler handler)` Registers a handler to be invoked when the Flutter application sends a message to its host platform.

- - ### Method Detail

    - #### send

          @UiThread
          void send(@NonNull
                              String channel,
                              @Nullable
                              ByteBuffer message)

      Sends a binary message to the Flutter application.
      Parameters:
        `channel` - the name `String` of the logical channel used for the message.
        `message` - the message payload, a direct-allocated `ByteBuffer` with the message bytes between position zero and current position, or null.

    - #### send

          @UiThread
          void send(@NonNull
                              String channel,
                              @Nullable
                              ByteBuffer message,
                              @Nullable
                              BinaryMessenger.BinaryReply callback)

      Sends a binary message to the Flutter application, optionally expecting a reply.

      Any uncaught exception thrown by the reply callback will be caught and logged.

      Parameters:
        `channel` - the name `String` of the logical channel used for the message.
        `message` - the message payload, a direct-allocated `ByteBuffer` with the message bytes between position zero and current position, or null.
        `callback` - a `BinaryMessenger.BinaryReply` callback invoked when the Flutter application responds to the message, possibly null.

    - #### setMessageHandler

          @UiThread
          void setMessageHandler(@NonNull
                                           String channel,
                                           @Nullable
                                           BinaryMessenger.BinaryMessageHandler handler)

      Registers a handler to be invoked when the Flutter application sends a message to its host platform.

      Registration overwrites any previous registration for the same channel name. Use a null handler to deregister.

      If no handler has been registered for a particular channel, any incoming message on that channel will be handled silently by sending a null reply.

      Parameters:
        `channel` - the name `String` of the channel.
        `handler` - a `BinaryMessenger.BinaryMessageHandler` to be invoked on incoming messages, or null.