strokeCap property

StrokeCap? strokeCap
final

Applies stroke cap to the start and end of the line. You can set StrokeCap.round to get a semi-circle or StrokeCap.square to get a semi-square at the edges of the line.

The default value is StrokeCap.butt which doesn't apply any cap at the ends.

  late List<Model> _lines;
  late MapShapeSource _mapSource;

  @override
  void initState() {
    _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,
            sublayers: [
              MapLineLayer(
                lines: List<MapLine>.generate(
                  _lines.length,
                  (int index) {
                    return MapLine(
                      from: _lines[index].from,
                      to: _lines[index].to,
                      strokeCap: StrokeCap.round,
                    );
                  },
                ).toSet(),
              ),
            ],
          ),
        ],
      ),
    );
  }

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

  MapLatLng from;
  MapLatLng to;
}

Implementation

final StrokeCap? strokeCap;