void main() {
var numbers = [5, 10, -4, 27, -8, 6, -2];
var sum1 = numbers.reduce((value, element) => value + element);
print("Sum 1: ${sum1}");
var sum2 = numbers.where((number) => number > 0).reduce((value, element) => value + element);;
print("Sum 2: ${sum2}");
}
Output
Sum 1: 34
Sum 2: 48