PluginEventChannel<T> class
A named channel for sending events to the framework-side using streams.
This is the platform-side equivalent of EventChannel. Whereas EventChannel receives a stream of events from platform plugins, this channel sends a stream of events to the handler listening on the framework-side.
If no codec is provided, then StandardMethodCodec is used. If no binaryMessenger is provided, then pluginBinaryMessenger, which sends messages to the framework-side, is used.
Channels created using this class implement two methods for subscribing to the event stream. The methods use the encoding of the specified codec.
The first method is listen
. When called, it begins forwarding
messages to the framework side when they are added to the
controller
. This triggers the StreamController.onListen callback
on the controller
.
The other method is cancel
. When called, it stops forwarding
events to the framework. This triggers the StreamController.onCancel
callback on the controller
.
Events added to the controller
when the framework is not
subscribed are silently discarded.
Constructors
- PluginEventChannel(String name, [MethodCodec codec = const StandardMethodCodec(), BinaryMessenger? binaryMessenger])
-
Creates a new plugin event channel.
const
Properties
- binaryMessenger → BinaryMessenger?
-
The messenger used by this channel to send platform messages.
final
- codec → MethodCodec
-
The message codec used by this channel.
final
-
controller
← StreamController<
T> -
Use setController instead.
no getter
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
The logical channel on which communication happens.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setController(
StreamController< T> ? controller) → void - Changes the stream controller for this event channel.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited