initialize method

Future<void> initialize()

Initialize the isolate

This method is called automatically when the first method is called. Manually initializing before first json de/encode can improve performance.

Implementation

Future<void> initialize() async {
  assert(_hasStartedInitialize == false,
      'initialize() can only be called once per isolate.');
  _hasStartedInitialize = true;
  await Isolate.spawn(
    _compute,
    _receivePort.sendPort,
    onExit: _receivePort.sendPort,
    onError: _receivePort.sendPort,
  );
  _sendPort = await _events.next;
  _createdIsolate.complete();
}