fromUrls static method
Future<InteropProject>
fromUrls(
{ - required String package,
- required String version,
- required Iterable<String> urls,
- required String targetPath,
- required String dirName,
- String? contextCheck,
- Iterable<String> distFiles = const [],
- List<String> uses = const [],
- String? targetMainFile,
- bool force = false,
})
Implementation
static Future<InteropProject> fromUrls({required String package, required String version, required Iterable<String> urls, required String targetPath, required String dirName, String? contextCheck, Iterable<String> distFiles = const [], List<String> uses = const [], String? targetMainFile, bool force = false}) async {
final transpiller = Transpiler(package: package, targetPath: targetPath, dirName: dirName, contextCheck: contextCheck, uses: uses, targetMainFile: targetMainFile, distFiles: distFiles.toList());
final dir = transpiller.dir;
final fileArgs = <String>[];
await Directory(dir('download')).create(recursive: true);
for (var x = 0; x < urls.length; x++) {
final url = urls.elementAt(x);
final uri = Uri.parse(url);
final name = basename(uri.path);
final filePath = dir('download/$x$name');
final file = File(filePath);
if (force || !file.existsSync()) {
final buf = await http.read(uri);
file.writeAsStringSync(buf);
}
fileArgs.add(filePath);
}
return transpiller._createProject(fileArgs: fileArgs, crawlTsFiles: false);
}