getLive method

Future<List<Covid19CountryAllStatus>> getLive (
  1. {@required String country,
  2. String status,
  3. String date}
)

Fetches live informations about a single country after a specific date.

Don't forget to specify the date parameter While specifying status parameter.

It returns a list of Covid19CountryAllStatus.

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

Implementation

Future<List<Covid19CountryAllStatus>> getLive(
    {@required String country, String status, String date}) async {
  var res = await _dio.get('/live/country/$country' +
      (status != null
          ? date != null
              ? '/status/$status/date/$date'
              : '/status/$status'
          : ''));
  var data = res.data;
  List<Covid19CountryAllStatus> list = List();

  for (var i in data) {
    list.add(
      Covid19CountryAllStatus(
        country: i['Country'],
        countryCode: i['CountryCode'],
        province: i['Province'],
        city: i['City'],
        cityCode: i['CityCode'],
        lat: i['Lat'],
        lon: i['Lon'],
        confirmed: i['Confirmed'],
        deaths: i['Deaths'],
        recovered: i['Recovered'],
        active: i['Active'],
        date: i['Date'],
      ),
    );
  }
  return list;
}