setWeight method

void setWeight(
  1. double? weight
)

Set the weight of the user.

Implementation

void setWeight(double? weight) {
  if (_weight == weight) return;
  _weight = switch (weightUnit) {
    MeasurementSystem.imperial => (weight ?? 0) / Conversion.kgToLbs.value,
    _ => weight,
  };
  int calories = _calculateRecommendedCalorie();
  if (calories > 0) {
    caloriesTarget = calories;
  }
}