getDayOne method

Future<List<Covid19CountryEx>> getDayOne (
  1. {@required String country,
  2. String status,
  3. bool live: false}
)

Fetches countries information since the day one.

It returns a list of Covid19CountryEx.

The status can be: 'confirmed', 'recovered' or 'deaths'.

Implementation

Future<List<Covid19CountryEx>> getDayOne(
    {@required String country, String status, bool live = false}) async {
  if (live && status == null) status = 'confirmed';
  var res = await _dio.get('/dayone/country/$country' +
      (status != null ? '/status/$status' : '') +
      (live ? '/live' : ''));
  var data = res.data;
  List<Covid19CountryEx> list = List();

  for (var i in data) {
    list.add(
      Covid19CountryEx(
        country: i['Country'],
        countryCode: i['CountryCode'],
        province: i['Province'],
        city: i['City'],
        cityCode: i['CityCode'],
        lat: i['Lat'],
        lon: i['Lon'],
        cases: i['Cases'],
        status: i['Status'],
        date: i['Date'],
      ),
    );
  }
  return list;
}