¿Hay algún ejemplo de `spawnUri (…)` en la biblioteca “dart: isolate”?
Hay unspawnUri(uri)
funcionar endart:isolate
, pero no encuentro ningún ejemplo. He adivinado su uso, pero ha fallado.
Supongamos que hay 2 archivos, en el primero, llamaráspawnUri
Para el 2º, y comunicarse con él.
first.dart
import "dart:isolate";
main() {
ReceivePort port = new ReceivePort();
port.receive((msg, _) {
print(msg);
port.close();
});
var c = spawnUri("./second.dart");
c.send(["Freewind", "enjoy dart"], port.toSendPort());
}
second.dart
String hello(String who, String message) {
return "Hello, $who, $message";
}
void isolateMain(ReceivePort port) {
port.receive((msg, reply) => reply.send(hello(msg[0], msg[1]));
}
main() {}
Pero este ejemplo no funciona. No sé cuál es el código correcto, ¿cómo solucionarlo?