bmi property

double? get bmi

Calculates Body Mass Index (BMI) based on weight and height.

Implementation

double? get bmi {
  if (_weight != null &&
      (_weight ?? 0) > 0 &&
      _height != null &&
      (_height ?? 0) > 0) {
    // Calculate BMI using weight (kg) divided by height squared (m^2).
    return ((_weight ?? 0) / pow((_height ?? 0), 2)).parseFormatted();
  }
  // Return null if weight or height is missing or invalid.
  return null;
}