import 'dart:isolate';
void heavyComputation(SendPort sendPort) {
int sum = 0;
for (int i = 0; i < 1000000000; i++) {
sum += i;
}
sendPort.send(sum);
}
void main() async {
ReceivePort receivePort = ReceivePort();
await Isolate.spawn(heavyComputation, receivePort.sendPort);
var result = await receivePort.first;
print('结果:$result');
}