List data = [1, 2, 3]; data.forEach((value) { if (value == 2) { // how to stop? } print(value); });
Dart does not support non-local returns, so returning from a callback won't break the loop. The reason it works in jQuery is that each() checks the value returned by the callback. Dart forEach callback returns void.
http://docs.jquery.com/Core/each