scriptSource property

Future<String> scriptSource

Implementation

Future<String> get scriptSource async {
  final typeSource = (await _getClass(executableType)).toSource();
  var builder = new StringBuffer();

  builder.writeln("import 'dart:async';");
  builder.writeln("import 'dart:isolate';");
  builder.writeln("import 'dart:mirrors';");
  imports?.forEach((import) {
    builder.writeln("import '$import';");
  });
  builder.writeln("""
Future main (List<String> args, Map<String, dynamic> message) async {
final sendPort = message['_sendPort'];
final executable = new $typeName(message);
final result = await executable.execute();
sendPort.send({"_result": result});
}
  """);
  builder.writeln(typeSource);

  builder.writeln((await _getClass(Executable)).toSource());
  for (var type in additionalTypes ?? []) {
    final source = await _getClass(type);
    builder.writeln(source.toSource());
  }

  if (additionalContents != null) {
    builder.writeln(additionalContents);
  }

  return builder.toString();
}