BasicMessageChannel<T> class

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.

See: flutter.io/platform-channels/

Constructors

BasicMessageChannel(String name, MessageCodec<T> codec)
Creates a BasicMessageChannel with the specified name and codec. [...]
const

Properties

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

Methods

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. [...]
setMockMessageHandler(Future<T> handler(T message)) → void
Sets a mock callback for intercepting messages sent on this channel. Messages may be null. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited