spawnDart method

Future<SpawnedIsolate> spawnDart(
  1. dynamic dartEntryPoint,
  2. List<String> args, {
  3. String? debugName,
  4. bool enableObservatory = false,
  5. bool runObservatory = false,
  6. bool usesSpawnedMain = false,
})

Spawn a Dart entry point (script, File or Uri).

Implementation

Future<SpawnedIsolate> spawnDart(dynamic dartEntryPoint, List<String> args,
    {String? debugName,
    bool enableObservatory = false,
    bool runObservatory = false,
    bool usesSpawnedMain = false}) {
  if (dartEntryPoint is File) {
    return spawnDartFile(dartEntryPoint, args,
        debugName: debugName,
        enableObservatory: enableObservatory,
        runObservatory: runObservatory,
        usesSpawnedMain: usesSpawnedMain);
  } else if (dartEntryPoint is Uri) {
    return spawnDartURI(dartEntryPoint, args,
        debugName: debugName,
        enableObservatory: enableObservatory,
        runObservatory: runObservatory,
        usesSpawnedMain: usesSpawnedMain);
  } else if (dartEntryPoint is String) {
    if (isDartFilePath(dartEntryPoint)) {
      var dartFile = File(dartEntryPoint);
      return spawnDartFile(dartFile, args,
          debugName: debugName,
          enableObservatory: enableObservatory,
          runObservatory: runObservatory,
          usesSpawnedMain: usesSpawnedMain);
    } else {
      return spawnDartScript(dartEntryPoint, args,
          debugName: debugName,
          enableObservatory: enableObservatory,
          runObservatory: runObservatory,
          usesSpawnedMain: usesSpawnedMain);
    }
  } else {
    throw StateError(
        'Unsupported Dart entry point! type: ${dartEntryPoint.runtimeType} > $dartEntryPoint');
  }
}