Interface BinaryMessenger

    • Method Detail

      • makeBackgroundTaskQueue

        @UiThread
        default BinaryMessenger.TaskQueue makeBackgroundTaskQueue()
        Creates a TaskQueue that executes the tasks serially on a background thread.

        There is no guarantee that the tasks will execute on the same thread, just that execution is serial.

      • 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.
      • setMessageHandler

        @UiThread
        default void setMessageHandler​(@NonNull
                                       String channel,
                                       @Nullable
                                       BinaryMessenger.BinaryMessageHandler handler,
                                       @Nullable
                                       BinaryMessenger.TaskQueue taskQueue)
        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.
        taskQueue - a BinaryMessenger.TaskQueue that specifies what thread will execute the handler. Specifying null means execute on the platform thread.