Answers for "flutter calculate sum in a list"

0

sum of a list using for loop in dart

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}");
}
Posted by: Guest on October-08-2020
0

flutter calculate sum in a list

// dart
import 'package:collection/collection.dart';

void main() {
  final list = [1, 2, 3, 4];
  final sum = list.sum;
  print(sum); // prints 10

}
Posted by: Guest on August-03-2021

Code answers related to "flutter calculate sum in a list"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language