getDownloadable method Null safety
Returns list of downloadable WSL distros
@return Future<List
Implementation
Future<List<String>> getDownloadable(
String repo, Function(String) onError) async {
try {
await Dio().get(repo).then((value) => {
value.data.split('\n').forEach((line) {
if (line.contains('tar.gz"') &&
line.contains('href=') &&
(line.contains('debian-10') || line.contains('debian-11'))) {
String name = line
.split('href="')[1]
.split('"')[0]
.toString()
.replaceAll('.tar.gz', '')
.replaceAll('1_amd64', '')
.replaceAll(RegExp(r'-|_'), ' ')
.replaceAllMapped(RegExp(r' .|^.'),
(Match m) => m[0].toString().toUpperCase());
distroRootfsLinks.addAll({
name: repo + line.split('href="')[1].split('"')[0].toString()
});
}
})
});
} catch (e) {
onError(e.toString());
}
List<String> list = [];
list.addAll(distroRootfsLinks.keys);
return list;
}