This forEach
works just fine
var newMarkers = new List<Marker>();
providers.forEach((p) {
var marker = markerFrom(p);
newMarkers.add(marker);
print("got one");
});
_markers = newMarkers;
but this map
doesn't ever get called when placed in the exact same place as the forEach
:
_markers = providers.map((p) => markerFrom(p));
Additionally, this is the markerFrom
method:
Marker markerFrom(FoodProvider provider) {
var marker = new Marker(new MarkerOptions()
..map = _map
..position = new LatLng(provider.latitude, provider.longitude)
..title = provider.name
..icon = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png'
);
var infoWindow = new InfoWindow(new InfoWindowOptions()..content = marker.title);
marker.onClick.listen((e) {
infoWindow.open(_map, marker);
});
return marker;
}
List<Marker>
,map
will produce anIterable
, so you have to do_markers = providers.map((p) => markerFrom(p)).toList();
, but it depends of what you want to do with_markers