//创建ReceivePort
var receiver = ReceivePort();
//rootIsolateToken 主要是为了在非主Isolate中调用Channel
RootIsolateToken rootIsolateToken = RootIsolateToken.instance!;
await Isolate.spawn(doTask, [receiver.sendPort,rootIsolateToken]);
//监听从子Isolate中发送过来的数据
receiver.listen((message){
});
void doTask(List params) async{
//params 就是 spawn方法的第二个参数
var sendPort = params[0];
var token = params[1];
/// 注册 root isolaote 保证在子Isolate中可以调用Channel
BackgroundIsolateBinaryMessenger.ensureInitialized(token);
//发送消息到主Isolate
sendPort.send(message)
}