downloadDebtFeedAsync method

Future<DebtList> downloadDebtFeedAsync({
  1. int pagesize = 10,
  2. int pagenum = 1,
})

Downloads the Debt to the Penny dataset from the US Treasury API, asynchronously.

Implementation

Future<DebtList> downloadDebtFeedAsync(
    {int pagesize = 10, int pagenum = 1}) async {
  final result = await http
      .get(Uri.parse(urlString(pagesize: pagesize, pagenum: pagenum)));

  final body = result.body;
  final jsonResponse = json.decode(body) as Map<String, dynamic>;

  final debtList = DebtList.listFromJSON(jsonResponse);

  return debtList;
}