MapPolygon class Null safety

Creates a closed path which connects multiple geographical coordinates through group of MapPolygon.points.

 late MapZoomPanBehavior _zoomPanBehavior;
 late List<MapLatLng> _polygon;
 late MapShapeSource _mapSource;

 @override
 void initState() {
   _polygon = <MapLatLng>[
     MapLatLng(38.8026, -116.4194),
     MapLatLng(46.8797, -110.3626),
     MapLatLng(41.8780, -93.0977),
   ];

   _mapSource = MapShapeSource.asset(
     'assets/usa.json',
     shapeDataField: 'name',
   );

   _zoomPanBehavior = MapZoomPanBehavior();
   super.initState();
 }

 @override
 Widget build(BuildContext context) {
   return Scaffold(
     appBar: AppBar(title: Text('Polygon shape')),
     body: SfMaps(layers: [
       MapShapeLayer(
         source: _mapSource,
         sublayers: [
           MapPolygonLayer(
             polygons: List<MapPolygon>.generate(
               1,
               (int index) {
                 return MapPolygon(
                   points: _polygon,
                 );
               },
             ).toSet(),
           ),
         ],
         zoomPanBehavior: _zoomPanBehavior,
       ),
     ]),
   );
 }
Inheritance

Constructors

MapPolygon({required List<MapLatLng> points, Color? color, Color? strokeColor, double? strokeWidth, VoidCallback? onTap})
Creates a MapPolygon.
const

Properties

color Color?
Specifies the fill color of the polygon. [...]
final
hashCode int
The hash code for this object. [...]
read-only, inherited
onTap VoidCallback?
Callback to receive tap event for this polygon. [...]
final
points List<MapLatLng>
The geolocation coordinates of the polygon to be drawn. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
strokeColor Color?
Specifies the stroke color of the polygon. [...]
final
strokeWidth double?
Specifies the stroke width of the polygon. [...]
final

Methods

debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object. [...]
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited