Call async function from Isolate function

。_饼干妹妹 提交于 2020-01-13 01:32:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!