DEV Community

Cover image for Como trabalhar com Loop no Dart
William Koller
William Koller

Posted on

2 2

Como trabalhar com Loop no Dart

Iremos iniciar uma lista

var list = [1, 2, 3, 4, 5, 6];
Enter fullscreen mode Exit fullscreen mode

Utilizando o método forEach

list.forEach((element) {
  print(element);
});
Enter fullscreen mode Exit fullscreen mode

Utilizando for Loop

for (int i = 0; i < list.length; i++) {
  var e = list[i];
  print(e);
}
Enter fullscreen mode Exit fullscreen mode

Utilizando for in Loop

for (var e in <List>[list]) {
  print(e);
}
Enter fullscreen mode Exit fullscreen mode

Utilizando while Loop

var i = 0;
while (i < list.length) {
  print(list[i]);
  i++;
}
Enter fullscreen mode Exit fullscreen mode

Repo:

loop-dart

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up