getAppleHealthWritePermissions method

Future<List<AppleHealthParameterType>> getAppleHealthWritePermissions()

Implementation

Future<List<AppleHealthParameterType>>
    getAppleHealthWritePermissions() async {
  final client = await _getClient();
  final healthPermissions = await getAppleHealthPermissionFromClient(client);

  List<AppleHealthParameterType> parameterTypes = [];

  for (final permission in healthPermissions) {
    if (permission.healthDataAccess == HealthDataAccess.READ_WRITE ||
        permission.healthDataAccess == HealthDataAccess.WRITE) {
      final parameterType =
          AppleHealth.getParameterFromDataType(permission.healthDataType);
      if (!parameterTypes.any((element) => element == parameterType)) {
        parameterTypes.add(parameterType);
      }
    }
  }

  return parameterTypes;
}