textStyle property
Customizes the data label's text style.
This snippet shows how to set textStyle 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(
textStyle: TextStyle(color: Colors.red)
),
)
],
);
}
class Model {
const Model(this.country, this.count, this.storage);
final String country;
final double count;
final String storage;
}
Implementation
final TextStyle? textStyle;