问题
I am trying to call an async function from the Isolate function.
class IsolateExample {
final ReceivePort port = new ReceivePort();
IsolateExample(){
Isolate.spawn(isolateFunction, port.sendPort);
}
static isolateFunction(SendPort port){
print('inside isolateFunction');
asyncFunction();
}
static void asyncFunction() async {
print('inside asyncFunction');
}
}
Usage of above class:
final IsolateExample _isolate = new IsolateExample();
Above code looks simple but asyncFunction never gets called. I do not have any clue why this is failing.
来源:https://stackoverflow.com/questions/50334869/call-async-function-from-isolate-function