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