TreemapLevel class Null safety

The levels collection which forms either flat or hierarchal treemap.

You can have more than one TreemapLevel in this collection to form a hierarchal treemap. The 0th index of the SfTreemap.levels collection forms the base level of the treemap or flat treemap. From the 1st index, the values returned in the TreemapLevel.groupMapper callback will form as inner tiles of the tile formed in the previous level for which the indices match.This hierarchy will go on till the last TreemapLevel in the Treemap.levels collection.

late List<SocialMediaUsers> _socialMediaUsersData;

  @override
  void initState() {
    _socialMediaUsersData = <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(
      body: SfTreemap(
        dataCount: _socialMediaUsersData.length,
        weightValueMapper: (int index) {
          return _socialMediaUsersData[index].usersInMillions;
        },
      levels: [
        TreemapLevel(
            color: Colors.red,
            padding: EdgeInsets.all(2),
            groupMapper: (int index) {
              return _socialMediaUsersData[index].country;
            }),
        ],
      ),
    );
  }

class SocialMediaUsers {
  const SocialMediaUsers(
    this.country,
    this.socialMedia,
    this.usersInMillions,
  );
  final String country;
  final String socialMedia;
  final double usersInMillions;
}

See also:

  • SfTreemap, to know how treemap render the tiles.
Inheritance
Annotations

Constructors

TreemapLevel({Color? color, RoundedRectangleBorder? border, EdgeInsetsGeometry? padding = const EdgeInsets.all(0.5), required IndexedStringValueMapper groupMapper, TreemapTileColorValueMapper? colorValueMapper, TreemapTileWidgetBuilder? tooltipBuilder, TreemapTileWidgetBuilder? labelBuilder, TreemapTileWidgetBuilder? itemBuilder})
Creates a TreemapLevel. [...]
const

Properties

border RoundedRectangleBorder?
Specifies the border of the rectangular box with rounded corners. [...]
final
color Color?
Specifies the color applied to the tiles. [...]
final
colorValueMapper TreemapTileColorValueMapper?
Returns a color or value based on which tile color will be updated. [...]
final
groupMapper IndexedStringValueMapper
Returns the group to be mapped based on the data source. [...]
final
hashCode int
The hash code for this object. [...]
read-only, override
itemBuilder TreemapTileWidgetBuilder?
Returns a widget for the treemap tile based on the index. [...]
final
labelBuilder TreemapTileWidgetBuilder?
Returns a widget for the treemap label based on the tile. [...]
final
padding EdgeInsetsGeometry?
Sets the padding around the tiles based on the value. [...]
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
tooltipBuilder TreemapTileWidgetBuilder?
Returns a widget for the tooltip based on the treemap tile. [...]
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