BasicMessageChannel<T> class Null safety

A named channel for communicating with platform plugins using asynchronous message passing.

Messages are encoded into binary before being sent, and binary messages received are decoded into Dart values. The MessageCodec used must be compatible with the one used by the platform plugin. This can be achieved by creating a basic message channel counterpart of this channel on the platform side. The Dart type of messages sent and received is T, but only the values supported by the specified MessageCodec can be used. The use of unsupported values should be considered programming errors, and will result in exceptions being thrown. The null message is supported for all codecs.

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


Available Extensions


BasicMessageChannel(String name, MessageCodec<T> codec, {BinaryMessenger? binaryMessenger})
Creates a BasicMessageChannel with the specified name, codec and binaryMessenger. [...]


binaryMessenger BinaryMessenger
The messenger which sends the bytes for this channel, not null.
codec MessageCodec<T>
The message codec used by this channel, not null.
hashCode int
The hash code for this object. [...]
read-only, inherited
name String
The logical channel on which communication happens, not null.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
send(T message) Future<T?>
Sends the specified message to the platform plugins on this channel. [...]
setMessageHandler(Future<T> handler(T? message)?) → void
Sets a callback for receiving messages from the platform plugins on this channel. Messages may be null. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]