PlatformWebMessagePort class abstract
The representation of the HTML5 message ports.
A Message port represents one endpoint of a Message Channel. In Android webview, there is no separate Message Channel object. When a message channel is created, both ports are tangled to each other and started. See InAppWebViewController.createWebMessageChannel for creating a message channel.
When a message port is first created or received via transfer, it does not have a WebMessageCallback to receive web messages. On Android, the messages are queued until a WebMessageCallback is set.
A message port should be closed when it is not used by the embedder application anymore. A closed port cannot be transferred or cannot be reopened to send messages. Close can be called multiple times.
When a port is transferred to JavaScript, it cannot be used to send or receive messages at the Dart side anymore. Different from HTML5 Spec, a port cannot be transferred if one of these has ever happened: i. a message callback was set, ii. a message was posted on it. A transferred port cannot be closed by the application, since the ownership is also transferred.
It is possible to transfer both ports of a channel to JavaScript, for example for communication between subframes.
- Inheritance
-
- Object
- PlatformInterface
- PlatformWebMessagePort
- Implemented types
Constructors
- PlatformWebMessagePort(PlatformWebMessagePortCreationParams params)
-
Creates a new PlatformWebMessagePort
factory
- PlatformWebMessagePort.implementation(PlatformWebMessagePortCreationParams params)
- Used by the platform implementation to create a new PlatformWebMessagePort.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- params → PlatformWebMessagePortCreationParams
-
The parameters used to initialize the PlatformWebMessagePort.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → Future< void> -
Close the message port and free any resources associated with it.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
postMessage(
WebMessage message) → Future< void> -
Post a WebMessage to the entangled port.
inherited
-
setWebMessageCallback(
WebMessageCallback? onMessage) → Future< void> -
Sets a callback to receive message events on the main thread.
inherited
-
toJson(
) → Map< String, dynamic> -
inherited
-
toMap(
) → Map< String, dynamic> -
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited