-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Add clearMarkers() functionality to GoogleMapController #843
Conversation
548f882
to
a1e56a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
LGTM with one nit
Future<void> clearMarkers() async { | ||
assert(_markers != null); | ||
await _markers.forEach((String id, Marker marker) async { | ||
await _channel.invokeMethod('marker#remove', <String, dynamic>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be nice to extract the common part for this and removeMarker
to a private method (mainly so we have a single copy of 'marker#remove'
in the dart code)
…d by controller#removeMarker and controller#clearMarkers.
assert(_markers != null); | ||
_markers.forEach((String id, Marker marker) async { | ||
await _removeMarker(id); | ||
_markers.remove(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this can be moved into _removeMarker
notifyListeners(); | ||
} | ||
|
||
void _removeMarker(String id) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should return a Future so we can await it
/// The returned [Future] completes once listeners have been notified. | ||
Future<void> clearMarkers() async { | ||
assert(_markers != null); | ||
_markers.forEach((String id, Marker marker) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that nothing awaits the closure passed to forEach, so the notifyListeners will happen immediately and the clearMarkers method will complete immediately...
Add clearMarkers() functionality to GoogleMapController. This method will clear all markers currently present on the map.
Add a method to clear all the markers currently on the map. There is currently a method to add, update, and remove a single marker, but not a method to remove all markers.