iconType property
Specifies the shape of the legend icon.
Defaults to TreemapIconType.circle.
late List<SocialMediaUsers> _source;
@override
void initState() {
_source = <SocialMediaUsers>[
SocialMediaUsers('India', 'Facebook', 280),
SocialMediaUsers('India', 'Instagram', 88),
SocialMediaUsers('USA', 'Facebook', 190),
SocialMediaUsers('USA', 'Instagram', 120),
SocialMediaUsers('Japan', 'Twitter', 48),
SocialMediaUsers('Japan', 'Instagram', 31),
];
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Treemap legend')),
body: SfTreemap.dice(
dataCount: _source.length,
weightValueMapper: (int index) {
return _source[index].usersInMillions;
},
levels: [
TreemapLevel(
padding: EdgeInsets.only(left: 2.5, right: 2.5),
groupMapper: (int index) {
return _source[index].country;
},
color: Colors.teal,
),
],
legend: TreemapLegend(
iconType: TreemapIconType.diamond,
),
),
);
}
class SocialMediaUsers {
const SocialMediaUsers(
this.country,
this.socialMedia,
this.usersInMillions,
);
final String country;
final String socialMedia;
final double usersInMillions;
}
See also:
- iconSize, to set the size of the icon.
Implementation
final TreemapIconType iconType;