read method

  1. @override
Future<ProcessedData> read(
  1. HealthResource resource,
  2. DateTime startDate,
  3. DateTime endDate
)

Implementation

@override
Future<ProcessedData> read(
    HealthResource resource, DateTime startDate, DateTime endDate) async {
  try {
    if (resource == HealthResource.caffeine ||
        resource == HealthResource.mindfulSession) {
      throw UnsupportedResourceException(
          "Resource $resource is not supported on Android");
    }

    final result = await _channel.invokeMethod('read', <String, dynamic>{
      "resource": resource.name,
      "startDate": startDate.millisecondsSinceEpoch,
      "endDate": endDate.millisecondsSinceEpoch,
    });

    return _mapJsonToProcessedData(resource, jsonDecode(result));
  } on Exception catch (e) {
    throw _mapException(e);
  }
}