isolate method
Future
isolate(
- Future function(
- dynamic
), {
- dynamic args,
})
Implementation
Future<dynamic> isolate(Future Function(dynamic) function,
{dynamic args}) async {
if (kIsWeb) {
return await function(args);
}
final ReceivePort receivePort = ReceivePort();
RootIsolateToken rootToken = RootIsolateToken.instance!;
await Isolate.spawn<_IsolateData>(
_isolateEntry,
_IsolateData(
token: rootToken,
function: function,
answerPort: receivePort.sendPort,
args: args,
),
);
return await receivePort.first;
}