# FlutterEventChannel

Objective-C

    @interface FlutterEventChannel : NSObject

Swift

    class FlutterEventChannel : NSObject

A channel for communicating with the Flutter side using event streams.

- `+eventChannelWithName:binaryMessenger:`

  Creates a `FlutterEventChannel` with the specified name and binary messenger.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterViewController`.

  The channel uses `FlutterStandardMethodCodec` to decode stream setup and teardown requests, and to encode event envelopes.

  #### Declaration

  Objective-C

      + (nonnull instancetype)
          eventChannelWithName:(nonnull NSString *)name
               binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger;

  Swift

      convenience init(name: String, binaryMessenger messenger: FlutterBinaryMessenger)

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.

- `+eventChannelWithName:binaryMessenger:codec:`

  Creates a `FlutterEventChannel` with the specified name, binary messenger, and method codec.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterViewController`.

  #### Declaration

  Objective-C

      + (nonnull instancetype)
          eventChannelWithName:(nonnull NSString *)name
               binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                         codec:(nonnull NSObject<FlutterMethodCodec> *)codec;

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The method codec.

- `-initWithName:binaryMessenger:codec:`

  Initializes a `FlutterEventChannel` with the specified name, binary messenger, and method codec.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterEngine` and `FlutterViewController`.

  #### Declaration

  Objective-C

      - (nonnull instancetype)
             initWithName:(nonnull NSString *)name
          binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                    codec:(nonnull NSObject<FlutterMethodCodec> *)codec;

  Swift

      init(name: String, binaryMessenger messenger: FlutterBinaryMessenger, codec: FlutterMethodCodec & NSObjectProtocol)

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The method codec.

- `-initWithName:binaryMessenger:codec:taskQueue:`

  Initializes a `FlutterEventChannel` with the specified name, binary messenger, method codec and task queue.

  The channel name logically identifies the channel; identically named channels interfere with each other’s communication.

  The binary messenger is a facility for sending raw, binary messages to the Flutter side. This protocol is implemented by `FlutterEngine` and `FlutterViewController`.

  #### Declaration

  Objective-C

      - (nonnull instancetype)
             initWithName:(nonnull NSString *)name
          binaryMessenger:(nonnull NSObject<FlutterBinaryMessenger> *)messenger
                    codec:(nonnull NSObject<FlutterMethodCodec> *)codec
                taskQueue:(NSObject<FlutterTaskQueue> *_Nullable)taskQueue;

  #### Parameters

  `name` | The channel name.
  `messenger` | The binary messenger.
  `codec` | The method codec.
  `taskQueue` | The FlutterTaskQueue that executes the handler (see -[FlutterBinaryMessenger makeBackgroundTaskQueue]).

- `-setStreamHandler:`

  Registers a handler for stream setup requests from the Flutter side.

  Replaces any existing handler. Use a `nil` handler for unregistering the existing handler.

  #### Declaration

  Objective-C

      - (void)setStreamHandler:(NSObject<FlutterStreamHandler> *_Nullable)handler;

  Swift

      func setStreamHandler(_ handler: (FlutterStreamHandler & NSObjectProtocol)?)

  #### Parameters

  `handler` | The stream handler.

© 2023 Flutter. All rights reserved. (Last updated: 2023-02-17)

Generated by jazzy ♪♫ v0.14.3, a Realm project.