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.
All BasicMessageChannels provided by the Flutter framework guarantee FIFO ordering. Applications can assume messages sent via a built-in BasicMessageChannel are delivered in the same order as they're sent.
- Available Extensions
Constructors
-
BasicMessageChannel(String name, MessageCodec<
T> codec, {BinaryMessenger? binaryMessenger}) -
Creates a BasicMessageChannel with the specified name, codec and
binaryMessenger
.const
Properties
- binaryMessenger → BinaryMessenger
-
The messenger which sends the bytes for this channel.
no setter
-
codec
→ MessageCodec<
T> -
The message codec used by this channel, not null.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
The logical channel on which communication happens, not null.
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
-
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.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited