Avoid redundant setState call

This commit is contained in:
ashilkn
2025-07-15 15:52:42 +05:30
parent c318162feb
commit 03c116c2ba

View File

@@ -627,6 +627,8 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader> {
widget
.getSectionedListSliverRenderBoxYOffsetRelativeToStackRenderBox()!;
if (normalizedScrollOffset < 0) {
// No change in group ID, no need to call setState
if (currentGroupId == null) return;
currentGroupId = null;
} else {
final groupScrollOffsets = widget.galleryGroups.groupScrollOffsets;
@@ -659,6 +661,12 @@ class _PinnedGroupHeaderState extends State<PinnedGroupHeader> {
high = mid - 1;
}
}
if (currentGroupId ==
widget.galleryGroups
.scrollOffsetToGroupIdMap[groupScrollOffsets[floorIndex]]) {
// No change in group ID, no need to call setState
return;
}
currentGroupId = widget.galleryGroups
.scrollOffsetToGroupIdMap[groupScrollOffsets[floorIndex]];
}