dashArray property

List<double>? dashArray
final

Apply dash pattern for the line.

A sequence of dash and gap will be rendered based on the values in this list. Once all values of the list is rendered, it will be repeated again till the end of the line.

  late List<Model> _lines;
  late MapZoomPanBehavior _zoomPanBehavior;
  late MapShapeSource _mapSource;

  @override
  void initState() {
    _zoomPanBehavior = MapZoomPanBehavior(
      focalLatLng: MapLatLng(40.7128, -95.3698),
      zoomLevel: 3,
    );

    _mapSource = MapShapeSource.asset(
      "assets/world_map.json",
      shapeDataField: "continent",
    );

    _lines = <Model>[
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(44.9778, -93.2650)),
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(33.4484, -112.0740)),
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(29.7604, -95.3698)),
      Model(MapLatLng(40.7128, -74.0060), MapLatLng(39.7392, -104.9903)),
    ];

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfMaps(
        layers: [
          MapShapeLayer(
            source: _mapSource,
            zoomPanBehavior: _zoomPanBehavior,
            sublayers: [
              MapLineLayer(
                lines: List<MapLine>.generate(
                  _lines.length,
                  (int index) {
                    return MapLine(
                      from: _lines[index].from,
                      to: _lines[index].to,
                      dashArray: [8, 3, 4, 3],
                    );
                  },
                ).toSet(),
              ),
            ],
          ),
        ],
      ),
    );
  }

class Model {
  Model(this.from, this.to);

  MapLatLng from;
  MapLatLng to;
}

See also: * The MapLineLayer.dashArray, to apply same dash pattern for all lines.

Implementation

final List<double>? dashArray;