init static method

Implementation

static Future<CactusContext> init(CactusInitParams params) async {
  debugPrint('Starting CactusContext.init...');
  final context = CactusContext._();
  context.initParams = params;
  final resolvedParams = await _resolveParams(params);

  debugPrint('Spawning isolate...');
  final mainReceivePort = ReceivePort();
  await Isolate.spawn(_isolateEntry, mainReceivePort.sendPort);
  context._isolateSendPort = await mainReceivePort.first as SendPort;
  mainReceivePort.close();
  debugPrint('Isolate spawned, sending init command...');

  final result = await context._sendCommand(['init', _SendableInitParams.fromOriginal(resolvedParams)]);
  debugPrint('Init command result: $result');
  if (result is Exception) throw result;
  return context;
}