openfoodfacts / openfoodfacts-dart

Open Food Facts API Wrapper
https://pub.dev/packages/openfoodfacts
Apache License 2.0
157 stars 65 forks source link

Sending null from the SDK? #944

Open CharlesNepote opened 1 week ago

CharlesNepote commented 1 week ago

Copy/pasting a discussion with a user of the dart package: Me:

  1. about the energy: you should not add a computed value for energy, for many reasons: depending on the countries, energy is not computed the same way (between 4.2 and 4.4 kJ per kcal); in some countries (eg. the USA :wink:) products only use calories (we do compute kJ when kCal are entered, but it should be the decision of each player; we provide computed energy through the API as an independent field energy_100g)
  2. if you enter a new value for kCal and the user has not entered a value for kJ, you should reset the value of kJ (because this one is now probably false) (edited)

Them: "For 1 & 2, how should we go about resetting kJ? From the data quality report it seemed like our prior approach of not including kJ in the payload does not reset it. Does sending an explicit null in the dart SDK reset it?"

monsieurtanuki commented 1 week ago

@CharlesNepote In the dart code we don't compute anything related to nutrients, like energy or sodium.

We can unset a nutrient value by setting explicitly a null value. I've just managed to

Don't know if that answers all your questions.