covertQuantityTypesToHealthDataType function

List<HealthPermission> covertQuantityTypesToHealthDataType(
  1. List<AppleQuantityTypeClient?> quantityTypes
)

Implementation

List<HealthPermission> covertQuantityTypesToHealthDataType(
    List<AppleQuantityTypeClient?> quantityTypes) {
  final List<HealthPermission> healthPermissions = [];
  for (AppleQuantityTypeClient? element in quantityTypes) {
    for (HealthDataType healthDataType in HealthDataType.values) {
      if (healthDataType.name == element?.appleQuantityType?.quantityType) {
        healthPermissions.add(
          HealthPermission(
            healthDataType: healthDataType,
            healthDataAccess: getHealthDataAccessFromString(
              element?.permissionType,
            ),
          ),
        );
      }
    }
  }

  return healthPermissions;
}