DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

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

Posted on

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)

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.