FlutterEventChannel

@interface FlutterEventChannel : NSObject

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

  • 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;

    Parameters

    name

    The channel name.

    messenger

    The binary messenger.

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

  • 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;

    Parameters

    name

    The channel name.

    messenger

    The binary messenger.

    codec

    The method codec.

  • 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;

    Parameters

    handler

    The stream handler.