edgeLabelsPlacement property

MapLegendEdgeLabelsPlacement edgeLabelsPlacement
final

Place the edge labels either inside or outside of the bar legend.

edgeLabelsPlacement doesn't works with MapLegendLabelsPlacement.betweenItems.

Defaults to MapLegendEdgeLabelsPlacement.inside.

This snippet shows how to set edge label placement in SfMaps.

 late List<DataModel> _data;
 late MapShapeSource _mapSource;

  @override
  void initState() {
    super.initState();

    _data = <DataModel>[
      DataModel('India', 100, "Low"),
      DataModel('United States of America', 200, "High"),
      DataModel('Pakistan', 75, "Low"),
    ];

    _mapSource = MapShapeSource.asset("assets/world_map.json",
        shapeDataField: "name",
        dataCount: _data.length, primaryValueMapper: (int index) {
      return _data[index].country;
    }, shapeColorValueMapper: (int index) {
      return _data[index].count;
    }, shapeColorMappers: [
      MapColorMapper(from: 0, to: 100, color: Colors.red),
      MapColorMapper(from: 101, to: 200, color: Colors.yellow)
    ]);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Bar legend')),
      body: SfMaps(
        layers: [
          MapShapeLayer(
            source: _mapSource,
            legend: MapLegend.bar(
              MapElement.shape,
              edgeLabelsPlacement: MapLegendEdgeLabelsPlacement.inside,
            ),
          )
        ],
      ),
    );
  }
}

class DataModel {
  const DataModel(this.country, this.count, this.storage);

  final String country;
  final double count;
  final String storage;
}

See also:

  • labelsPlacement, place the labels either between the segments or on the segments.
  • labelOverflow, to trims or removes the legend text when it is overflowed from the bar legend.

Implementation

final MapLegendEdgeLabelsPlacement edgeLabelsPlacement;