Check out example codes for "sum of a list using for loop in dart". It will help you in understanding the concepts better.

Code Example 1

main(List<string> args) {
  var sum = 0;
  var given_list = [1, 2, 3, 4, 5];

  for (var i = 0; i < given_list.length; i++) {
    sum += given_list[i];
  }

  print("Sum : ${sum}");
}

Learn ReactJs, React Native from akashmittal.com