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
andFlutterViewController
.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.
-
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
andFlutterViewController
.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]).
-
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.