overflowMode property

MapLabelOverflow overflowMode
final

Trims or removes the data label when it is overflowed from the shape.

Defaults to MapLabelOverflow.visible.

By default, the data labels will render even if it overflows form the shape. Using this property, it is possible to remove or trim the data labels based on the available space in the shape.

This snippet shows how to set the overflowMode for the data labels in SfMaps.

late List<Model> _data;
late MapShapeSource _mapSource;

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

   _data = <Model>[
    Model('India', 280, "Low"),
    Model('United States of America', 190, "High"),
    Model('Pakistan', 37, "Low"),
   ];

   _mapSource = MapShapeSource.asset(
     "assets/world_map.json",
     shapeDataField: "name",
     dataCount: _data.length,
     primaryValueMapper: (int index) {
       return _data[index].country;
     },
     dataLabelMapper: (int index) {
       return _data[index].country;
     },
  );
 }

 @override
 Widget build(BuildContext context) {
   return SfMaps(
     layers: [
       MapShapeLayer(
         showDataLabels: true,
         source: _mapSource,
          dataLabelSettings:
               MapDataLabelSettings(
                   overflowMode: MapLabelOverflow.hide
               ),
       )
     ],
   );
 }

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

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

Implementation

final MapLabelOverflow overflowMode;