onMain method

void onMain(
  1. dynamic data,
  2. Completer _completer
)

Implementation

void onMain(data, Completer _completer) {
  try {
    if (data is GetIsolateEntry) {
      $debugPrint("init: $data", "MainPort");
      final isolatePort = data.sendPort;
      _completer.complete(isolatePort);
    } else if (data is GetRequestParcel) {
      $debugPrint(data.typeName, "MainPort");
      completer[data.key]?.complete(data.result);
    }
  } catch (e) {
    $debugPrint("Error: $e", "MainPort");
  }
}