sortAscending property

bool sortAscending
final

Sort the tiles based on the value returned from the weightValueMapper callback.

  • If true, the tiles will be arranged from smallest to largest.
  • If false, the tiles will be arranged from largest to smallest.

Defaults to false.

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.slice(
      dataCount: _socialMediaUsersData.length,
      weightValueMapper: (int index) {
        return _socialMediaUsersData[index].usersInMillions;
      },
      sortAscending: true,
      levels: [
        TreemapLevel(
            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:

Implementation

final bool sortAscending;