foreach和map都是可以用的:
_items(BuildContext context) {
if (localNavList == null) return null;
List<Widget> items = [];
// localNavList.forEach((model) {
// items.add(_item(context, model));
// });
//等价于
items = localNavList.map((model) => _item(context, model)).toList();
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: items,
);
}