MapDataLabelSettings class Null safety

Customizes the appearance of the data labels.

It is possible to customize the style of the data labels, hide or trim the data labels when it exceeds their respective shapes.

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(
                   textStyle: TextStyle(color: Colors.red)
               ),
       )
     ],
   );
 }

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

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

Constructors

MapDataLabelSettings({TextStyle? textStyle, MapLabelOverflow overflowMode = MapLabelOverflow.visible})
Creates a MapDataLabelSettings.
const

Properties

hashCode int
The hash code for this object. [...]
read-only, override
overflowMode MapLabelOverflow
Trims or removes the data label when it is overflowed from the shape. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
textStyle TextStyle?
Customizes the data label's text style. [...]
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. [...]
override