I'm using google_maps_flutter plugin to use google maps. I want to draw a polygon on google maps with coordinates taken from the user. The coordinates taken are type of 'Position' object.
I have already tried using map_view plugin to draw polygons. But it didn't work for me.
This is the code snippet where the coordinates are being taken.
Geolocator geolocator = Geolocator();
StreamSubscription<Position> _positionStreamSubscription;
final List<Position> _positions = <Position>[];
void _toggleListening() {
if (_positionStreamSubscription == null) {
const LocationOptions locationOptions =
LocationOptions(accuracy: LocationAccuracy.best, distanceFilter: 10);
final Stream<Position> positionStream =
Geolocator().getPositionStream(locationOptions);
_positionStreamSubscription = positionStream.listen(
(Position position) => setState(() => _positions.add(position)));
_positionStreamSubscription.pause();
}
setState(() {
if (_positionStreamSubscription.isPaused) {
_positionStreamSubscription.resume();
} else {
_positionStreamSubscription.pause();
}
});