addPolygon method

Future<Polygon> addPolygon(
  1. PolygonOptions options, [
  2. Map? data
])

Adds a fill to the map, configured using the specified custom options.

Change listeners are notified once the fill has been added on the platform side.

The returned Future completes with the added fill once listeners have been notified.

Implementation

Future<Polygon> addPolygon(PolygonOptions options, [Map? data]) async {
  final effectiveOptions = PolygonOptions.defaultOptions.copyWith(options);
  final fill = Polygon(getRandomString(), effectiveOptions, data);
  await polygonManager!.add(fill);
  notifyListeners();
  return fill;
}