IsolateChild<S, R> class abstract

A child isolate that is spawned by another isolate

A subclass of this should override id to uniquely identify itself among other children.

  • Optionally override onSpawn to run code when the child isolate is spawned
  • Override onData to handle data sent by the parent isolate
  • Use sendToParent to send data to the parent isolate

The type arguments S and R represent the types of data that will be Sent and Received, from the child isolate's perspective. That is, if the parent sends integers and expects Strings, then S on the child should be String and R should be int -- the opposite of the parent.

Constructors

IsolateChild({required Object id})
Creates an isolate child with the given ID.

Properties

hashCode int
The hash code for this object.
no setterinherited
id Object
A unique identifier for this child to identify itself to the parent.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stream Stream<R>
A broadcast stream of all messages from the parent.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onData(R data) → void
A callback to run when new data is received from the parent.
onSpawn() Future<void>
Runs when the child isolate is spawned, after registerWithParent is called.
registerWithParent(TypedSendPort<ChildIsolatePayload<S, R>> port) Future<void>
Registers this child with its parent.
sendToParent(S obj) → void
Sends data to the parent isolate.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited