getLeaderboardTop10 method
Retrieves the top 10 drivers from the getLeaderboard.
This is a convenience method that returns the highest-ranked drivers without needing to specify offset and length parameters.
Returns:
List<LeaderBoardDriver>: List of top 10 drivers with their rankings
Usage:
try {
final topDrivers = await communicator.getLeaderboardTop10();
print('Top ${topDrivers.length} drivers:');
for (final driver in topDrivers) {
print('${driver.rank}: ${driver.name}');
}
} catch (e) {
print('Failed to get top 10: $e');
}
Throws:
Future.error("Unable to get top 10 getLeaderboard details"): When retrieval fails
Use Cases:
- Quick access to top performers
- Dashboard displays
- Competition highlights
Implementation
Future<List<LeaderBoardDriver>> getLeaderboardTop10() async {
try {
return await kruzr_comm.getLeaderboardTop10();
} on PlatformException catch (e) {
if (kDebugMode) {
print(e);
print("PlatformException in getLeaderboardTop10");
}
return Future.error({"code": e.code, "message": e.message, "details": e.details});
} on Exception catch (e) {
if (kDebugMode) {
print(e);
print("Exception in getLeaderboardTop10");
}
return Future.error(PlatformException(code: "PLUGIN_ERROR", message: e.toString()));
}
}