Last active
September 23, 2019 20:05
-
-
Save Zambrella/6966deed558a4024a13b448e227ccc11 to your computer and use it in GitHub Desktop.
Class to get the user bucket and total number of people
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'constants.dart'; | |
import 'package:http/http.dart' as http; | |
import 'dart:convert'; | |
class Brain { | |
Future<dynamic> getCumulativeCount({int userMMR}) async { | |
http.Response response = await http.get('$kURL?apikey=$kAPIKey'); | |
if (response.statusCode == 200) { | |
String responseData = response.body; | |
int mmrResponse = | |
jsonDecode(responseData)['mmr']['rows'][userMMR]['cumulative_sum']; | |
print(mmrResponse); | |
int mmrTotal = jsonDecode(responseData)['mmr']['sum']['count']; | |
print(mmrTotal); | |
double percentage = (mmrResponse / mmrTotal) * 100; | |
print(percentage.toStringAsPrecision(4)); | |
} else { | |
print(response.statusCode); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment