Flutter ETS API Documentation v1.0.0


Class: EventChannel

A named channel for communicating with the Flutter application using asynchronous event streams.

Incoming requests for event stream setup are decoded from binary on receipt, and responses and events are encoded into binary before being transmitted back to Flutter. The MethodCodec used must be compatible with the one used by the Flutter application. This can be achieved by creating an EventChannel counterpart of this channel on the Dart side. The type of stream configuration arguments, events, and error details is Any, but only values supported by the specified MethodCodec can be used.

The logical identity of the channel is given by its name. Identically named channels will interfere with each other's communication.

Constructors

Constructor

new EventChannel(messenger, name, codec?, taskQueue?): EventChannel

Constructs a new EventChannel instance.

Parameters

messenger

BinaryMessenger

The BinaryMessenger to use for communication

name

string

The channel name

codec?

MethodCodec

The MethodCodec to use for encoding/decoding, defaults to StandardMethodCodec.INSTANCE

taskQueue?

TaskQueue

Optional TaskQueue for background processing

Returns

EventChannel

Methods

setStreamHandler()

setStreamHandler(handler): void

Registers a stream handler on this channel.

Overrides any existing handler registration for (the name of) this channel.

If no handler has been registered, any incoming stream setup requests will be handled silently by providing an empty stream.

Parameters

handler

StreamHandler

A StreamHandler, or null to deregister

Returns

void