read method

Future<List<HealthData>> read (DataType type, { DateTime dateFrom, DateTime dateTo, int limit })

Implementation

static Future<List<HealthData>> read(
  DataType type, {
  DateTime dateFrom,
  DateTime dateTo,
  int limit,
}) async {
  return await _channel
      .invokeListMethod('read', {
        "type": _dataTypeToString(type),
        "date_from": dateFrom?.millisecondsSinceEpoch ?? 1,
        "date_to": (dateTo ?? DateTime.now()).millisecondsSinceEpoch,
        "limit": limit,
      })
      .then(
        (response) =>
            response.map((item) => HealthData.fromJson(item)).toList(),
      )
      .catchError(
        (_) => throw UnsupportedException(type),
        test: (e) {
          if (e is PlatformException) return e.code == 'unsupported';
          return false;
        },
      );
}