receive an event message
it seem not work to me
receive an event message
it seem not work to me
插件
这个插件是个啥啊
future是什么?
其实 Future 就是对于 Timer 和 microtask 甚至是同步调用的一层封装。这三者的简单用法分别是Future(), Future.microtask(),Future.sync()。
在异步函数中使用 await 关键字暂停代码的执行,直到对应的 future 完成。
我理解是否添加 await, 就是把下面函数写在回调里, 还是写在回调外的区别。
我们看个例子,利用Dart的Isolates实现多线程。
String sVal = '111';
void main() async { final rootIsolateReceivePort = ReceivePort(); sVal = '222';
Isolate spawnIsolate = await Isolate.spawn(spawnIsolateEntryPoint, rootIsolateReceivePort.sendPort); rootIsolateReceivePort.listen((message) { print('current: $sVal, spawn: $message'); }); sVal = '333'; print(sVal); }
void spawnIsolateEntryPoint(SendPort customCallback) { print(sVal); sVal = '444'; print(sVal); customCallback.send(sVal); }
scheduleMicrotask
想知道 Zone 是个什么东西