value property
Sets the value for the equal color mapping.
The shape or bubble will render in the specified color if the value returned in the MapShapeSource.shapeColorValueMapper or MapShapeSource.bubbleColorValueMapper is equal to this value.
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;
},
shapeColorValueMapper: (int index) {
return _data[index].storage;
},
shapeColorMappers: [
MapColorMapper(value: "Low", color: Colors.red),
MapColorMapper(value: "High", color: Colors.green)
],
);
}
@override
Widget build(BuildContext context) {
return SfMaps(
layers: [
MapShapeLayer(
source: _mapSource,
)
],
);
}
class Model {
const Model(this.country, this.count, this.storage);
final String country;
final double count;
final String storage;
}
See also:
- color, to set the color for the shape or bubble.
- MapShapeSource.shapeColorMappers, to set the shape colors based on the specific value.
- MapShapeSource.bubbleColorMappers, to set the bubble colors based on the specific value.
Implementation
final String? value;