List l1 = [1, 2];
//简写方式1:
l1.forEach((item) {
print(item);
});
//简写方式2:
l1.forEach((item) => print(item));
箭头函数只能有一行,可以省略大括号
参考:
http://www.ptbird.cn/dart-function-arrow-function-nameless-function-clojure.html#menu_index_6
List l1 = [1, 2];
//简写方式1:
l1.forEach((item) {
print(item);
});
//简写方式2:
l1.forEach((item) => print(item));
箭头函数只能有一行,可以省略大括号
参考:
http://www.ptbird.cn/dart-function-arrow-function-nameless-function-clojure.html#menu_index_6