Filter out scroll position divisions that are too close to each other

This commit is contained in:
ashilkn
2025-07-15 11:45:28 +05:30
parent 880594398d
commit d319b244ee

View File

@@ -82,8 +82,20 @@ class _CustomScrollBar2State extends State<CustomScrollBar2> {
);
}
}
final filteredResult = <({double position, String title})>[];
// Filter out positions that are too close to each other
if (result.isNotEmpty) {
filteredResult.add(result.first);
for (int i = 1; i < result.length; i++) {
if ((result[i].position - filteredResult.last.position).abs() >= 60) {
filteredResult.add(result[i]);
}
}
}
setState(() {
positionToTitleMap = result;
positionToTitleMap = filteredResult;
});
}