忘了更新此:/如果您查看问题中链接的代码
isolates_logging / lib / provider / test_isolate.dart
Future<void> _handle(int _m) async { final response = ReceivePort(); isolateTest = await Isolate.spawn(_isolate, response.sendPort); final sendPort = await response.first as SendPort; final answer = ReceivePort(); sendPort.send([_m, answer.sendPort]); await answer.first.then((p) { _outbound.sink.add(p);}); } static void _isolate(SendPort _initialReplyTo) { final port = ReceivePort(); _initialReplyTo.send(port.sendPort); port.listen((message) { final data = message[0] as int; final send = message[1] as SendPort; send.send(_syncHandle(data)); }); }}Future<String> _syncHandle(int data) async { return 'done';}
注意send.send(_syncHandle(data)); 部分
如果这样做,则只能发送基元,而不能发送期货,基本上就是这样
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)