convertWeightToG static method

double? convertWeightToG(
  1. double? value,
  2. Unit unit
)

Converts a double (weight) value from grams.

Typical use-case: sending a value to the BE.

Implementation

static double? convertWeightToG(double? value, Unit unit) {
  if (value == null) {
    return null;
  }
  final double? factor = _conversionFactorFromG[unit];
  if (factor != null) {
    return value / factor;
  }
  return value;
}