isEmpty method

bool isEmpty({
  1. bool isNullEmpty = false,
})

Returns true if there are no populated nutrients at all.

Default case: a nutrient with a null value is considered "populated". If isNullEmpty is true, a null value is a non populated value, and a Nutriments with only null values would be considered empty.

Implementation

bool isEmpty({final bool isNullEmpty = false}) {
  if (_map.isEmpty) {
    return true;
  }
  if (!isNullEmpty) {
    return false;
  }
  for (final double? value in _map.values) {
    if (value != null) {
      return false;
    }
  }
  return true;
}