TF-3507 Improve PullToRefreshWidget to increase performance

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-04-03 22:03:38 +07:00
committed by Dat H. Pham
parent bd20e32a30
commit 9363d4edbf
@@ -53,9 +53,18 @@ class _PullToRefreshWidgetState extends State<PullToRefreshWidget> {
return NotificationListener<ScrollNotification>(
onNotification: (notification) {
if (notification is ScrollUpdateNotification) {
setState(() {
_scrollOffset = notification.metrics.pixels;
});
final newOffset = notification.metrics.pixels;
final crossedThreshold =
(_scrollOffset.abs() <= widget.deepRefreshThreshold &&
newOffset.abs() > widget.deepRefreshThreshold) ||
(_scrollOffset.abs() > widget.deepRefreshThreshold &&
newOffset.abs() <= widget.deepRefreshThreshold);
if (crossedThreshold || _scrollOffset != newOffset) {
setState(() {
_scrollOffset = newOffset;
});
}
}
return false;
},