Skip to content

Conversation

@AcarFurkan
Copy link

@AcarFurkan AcarFurkan commented Dec 11, 2025

Problem

SfTreemap doesn't update when data values change if dataCount stays the same.

FR: https://www.syncfusion.com/feedback/47083/provide-dynamic-update-support-for-treemap-datasource-without-changing-the-data

Previous Workaround

The only way to force a rebuild was using a Key:

SfTreemap(
  key: ValueKey(Object.hashAll(data.map((e) => e.hashCode))),
  dataCount: data.length,
  // ...
)

Downsides:
- Forces complete widget rebuild (loses state, animations)
- Not intuitive - key is meant for widget identity, not data changes

Solution

Added optional rebuildToken parameter. When this value changes, the widget rebuilds
even if dataCount is unchanged.

SfTreemap(
  dataCount: data.length,
  rebuildToken: Object.hashAll(data.map((e) => e.hashCode)),
  // ...
)

Or simply use an int counter:

int _rebuildCounter = 0;

// When data changes:
setState(() {
  _rebuildCounter++;
});

SfTreemap(
  dataCount: data.length,
  rebuildToken: _rebuildCounter,
  // ...
)

Advantages:
- Clean, declarative API
- Explicit intent - clearly indicates "rebuild when data changes"
- No breaking changes - parameter is optional with default null

Demo

Before (no update):

before.mov

After (with rebuildToken):

UPDATED.mov

Fixes #1396

Fixes syncfusion#1396

Added optional rebuildToken parameter. When this value changes,
the widget rebuilds even if dataCount is unchanged.
@VijayakumarMariappan VijayakumarMariappan added tree map Treemap component open Open labels Dec 12, 2025
@VijayakumarMariappan
Copy link
Collaborator

VijayakumarMariappan commented Dec 15, 2025

Hi @AcarFurkan

Currently, the SfTreemap widget does not provide a direct method to refresh its data source without rebuilding. As a workaround, you can assign a new UniqueKey to the widget, which forces a full rebuild:

late UniqueKey _treemapKey;

void updateDataSource() {
  // If old and new data count is same
  _treemapKey = UniqueKey();

  // Else
  // No need to change the key
}

SfTreemap(
  key: _treemapKey,
  dataCount: data.length,
)

This approach will trigger a complete rebuild of the widget, which may reset its state or interrupt animations.

We have already logged your feedback for this feature request here: https://www.syncfusion.com/feedback/47083

At this time, we do not have immediate plans to implement this support. Please note that our Syncfusion Flutter packages are not open-source, so we are not currently accepting external contributions. However, your suggestion has been added to our prioritization list for future consideration.

Thank you for your understanding and continued support.

@AcarFurkan
Copy link
Author

Hi @VijayakumarMariappan ,
Thanks for the reply.

I already tried the key suggestion, but as you can see, when we use keys it doesn’t look good, and we can’t ship this to production like this:

before.mov

As you can also see, I’ve already added a small solution for this. It isn’t complicated and won’t break anything. I believe that if the developers take a look at my small changes, they’ll see that it’s very simple and brings good value

@VijayakumarMariappan
Copy link
Collaborator

Hi @AcarFurkan

I understand the challenges and limitations involved in using key replacement. While the proposed changes can serve as a temporary workaround, we won’t be able to include them in the source code. That said, we recognize the importance of this improvement and will prioritize finding a more robust solution. You can track the progress and updates through the feedback report link shared below.

Feedback report: https://www.syncfusion.com/feedback/47083

Thank you for your understanding and continued support.

@VijayakumarMariappan VijayakumarMariappan added uncertain Uncertain feature feature New feature and removed open Open labels Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature tree map Treemap component uncertain Uncertain feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

realtime update treemap chart when a item change

3 participants