MapPolygonLayer.inverted constructor

const MapPolygonLayer.inverted({
  1. Key? key,
  2. required Set<MapPolygon> polygons,
  3. double strokeWidth = 1,
  4. Color? color,
  5. Color? strokeColor,
  6. IndexedWidgetBuilder? tooltipBuilder,
})

Creates the inverted color polygon shape.

You can highlight particular on the map to make more readable by applying the opacity to the outer area of highlighted polygon area using the polygons property of MapPolygonLayer.inverted.

 late List<MapLatLng> _polygon;
 late MapShapeSource _dataSource;

  @override
  void initState() {
    _polygon = <MapLatLng>[
      MapLatLng(27.6648, -81.5158),
      MapLatLng(32.3078, -64.7505),
      MapLatLng(18.2208, -66.5901),
    ];

    _dataSource = MapShapeSource.asset(
      'assets/usa.json',
      shapeDataField: 'name',
    );
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfMaps(
        layers: [
          MapShapeLayer(
            source: _dataSource,
           sublayers: [
             MapPolygonLayer.inverted(
                polygons: List<MapPolygon>.generate(
                  1,
                 (int index) {
                    return MapPolygon(
                      points: _polygon,
                    );
                 },
                ).toSet(),
             ),
            ],
          ),
        ],
      ),
    );
  }

See also:
* [`MapPolygonLayer`], for adding normal polygon shape.

Implementation

const MapPolygonLayer.inverted({
  Key? key,
  required this.polygons,
  this.strokeWidth = 1,
  this.color,
  this.strokeColor,
  IndexedWidgetBuilder? tooltipBuilder,
})  : _fillType = _VectorFillType.outer,
      super(key: key, tooltipBuilder: tooltipBuilder);