isolate<T> method

Future<T?> isolate<T>(
  1. IsolationCallback<T> task,
  2. dynamic params
)

Implementation

Future<T?> isolate<T>(IsolationCallback<T> task, params) async {
  final responsePort = ReceivePort();
  _sendPort.send([
    [task, params],
    responsePort.sendPort
  ]);
  return responsePort.first.then((value) {
    return value is T ? value : null;
  });
}