I am having a challenge folding a list of integer elements to sum them up.
List<int> ints = [1,2,3,4,5];
var result = ints.fold(0, (pV,element)=>pV + element);
print(result);
Somehow I can't get this simple code to compile. I keep getting the error:
Error compiling to JavaScript:
Warning: Interpreting this as package URI, 'package:dartpad_sample/main.dart'.
lib/main.dart:19:46:
Error: The operator '+' isn't defined for the class 'Object?'.
- 'Object' is from 'dart:core'.
var result = ints.fold(0, (pV,element)=>pV + element);
^
Error: Compilation failed.
Any help