xxxxxxxxxx
// dart
import 'package:collection/collection.dart';
void main() {
final list = [1, 2, 3, 4];
final sum = list.sum;
print(sum); // prints 10
}
xxxxxxxxxx
int sum = [1, 2, 3].fold(0, (sum, current) => sum + current); // 6
int sum = [1, 2, 3].fold(0, (p, c) => p + c); // 6
xxxxxxxxxx
//Remember to cast return type
int sum = list.fold<int>(0, (int sum, int item) => sum + item);