totalValue property

num get totalValue

The sum of the values of the rolls.

Returns 0 if the rolls list is empty.

Throws an UnsupportedError if there are non-numeric rolls.

Implementation

num get totalValue {
  if (_rolls.every((r) => r is num)) {
    return _rolls.cast<num>().fold<num>(0, (a, b) => a + b);
  }
  throw UnsupportedError(
      'Cannot calculate totalValue because at least one roll value was not numeric');
}