createIsolate method Null safety

Future<WebIsolateManagerImpl> createIsolate(
  1. IsolateRun run,
  2. IsolateInitializer initializer,
  3. IsolateInitializeArguments args
)

Implementation

static Future<WebIsolateManagerImpl> createIsolate(
  IsolateRun run,
  IsolateInitializer initializer,
  IsolateInitializeArguments args
) async {
  final fromIsolate = StreamController<Event>.broadcast();
  final toIsolate = StreamController<Event>.broadcast();
  final sendFromIsolate = fromIsolate.add;
  final sendToIsolate = toIsolate.add;
  final toIsolateStream = toIsolate.stream;
  final fromIsolateStream = fromIsolate.stream;

  final isolateMessenger = IsolateMessenger(fromIsolateStream, sendToIsolate);

  // this function run isolated function (IsolateRun)
  run(IsolateMessenger(toIsolateStream, sendFromIsolate), initializer, args);

  return WebIsolateManagerImpl(
    WebIsolateWrapper(),
    isolateMessenger,
  );
}