You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to this repository
i have testing the Language Breakdown
and i found the exact solution
here is response and code below
Future loadRepositories()async{
var github = createClient(AppConstantNames.personalAccessToken);
// github.users.getCurrentUser().then((final CurrentUser user) {
// log(user.login!);
// });
Repository repo = await github.repositories.getRepository(RepositorySlug('amirVirtuenetz', 'App-Navigation-Flutter'));
final abcrepo=RepositorySlug('amirVirtuenetz', 'App-Navigation-Flutter');
breakdown=await github.repositories.listLanguages(abcrepo);
print(breakdown.runtimeType);
loadLanguage();
print("heis is dfsdf");
}
void loadLanguage({int accuracy=4}){
var github=GitHub();
final md=generateMarkDown(accuracy);
github.misc.renderMarkdown(md).then((value){
log("value $value");
});
}
int totalBytes(LanguageBreakdown breakdown) {
return breakdown.info.values.reduce((a, b) => a + b);
}
String generateMarkDown(int accuracy){
final total = totalBytes(breakdown);
final data = breakdown.toList();
var md = StringBuffer('''
|Name|Bytes|Percentage|
|-----|-----|-----|
''');
data.sort((a, b) => b[1].compareTo(a[1]));
for (final info in data) {
final String? name = info[0];
final int bytes = info[1];
final num percentage = (bytes / total) * 100;
md.writeln('|$name|$bytes|${percentage.toStringAsFixed(2)}|');
}
// log("List Language Data ${md}");
return md.toString();
}
and response is like excatly that in my github repository languages shwoing
output:
my question is that , I am using the GitHub rest API of list of lanugage
here is api: https://api.github.com/repos/OWNER/REPO/languages
i have cover all the basics step to authenticate now i got the response from this api is
{"Dart":178241,"C++":16824,"CMake":7951,"HTML":3938,"C":734,"Swift":404,"Kotlin":130,"Objective-C":38}
how can i convert number of bytes of code into percentage?
thank you!
The text was updated successfully, but these errors were encountered:
According to this repository
i have testing the Language Breakdown
and i found the exact solution
here is response and code below
Future loadRepositories()async{
}
int totalBytes(LanguageBreakdown breakdown) {
return breakdown.info.values.reduce((a, b) => a + b);
}
String generateMarkDown(int accuracy){
final total = totalBytes(breakdown);
final data = breakdown.toList();
var md = StringBuffer('''
|Name|Bytes|Percentage|
|-----|-----|-----|
''');
data.sort((a, b) => b[1].compareTo(a[1]));
for (final info in data) {
final String? name = info[0];
final int bytes = info[1];
final num percentage = (bytes / total) * 100;
md.writeln('|$name|$bytes|${percentage.toStringAsFixed(2)}|');
}
// log("List Language Data ${md}");
return md.toString();
}
and response is like excatly that in my github repository languages shwoing
output:
|C++|16824|8.08| |CMake|7951|3.82| |HTML|3938|1.89| |C|734|0.35| |Swift|404|0.19| |Kotlin|130|0.06| |Objective-C|38|0.02|
my question is that , I am using the GitHub rest API of list of lanugage here is api: https://api.github.com/repos/OWNER/REPO/languages i have cover all the basics step to authenticate now i got the response from this api is {"Dart":178241,"C++":16824,"CMake":7951,"HTML":3938,"C":734,"Swift":404,"Kotlin":130,"Objective-C":38} how can i convert number of bytes of code into percentage? thank you!The text was updated successfully, but these errors were encountered: