TF-3507 Improve PullToRefreshWidget to increase performance
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -53,9 +53,18 @@ class _PullToRefreshWidgetState extends State<PullToRefreshWidget> {
|
|||||||
return NotificationListener<ScrollNotification>(
|
return NotificationListener<ScrollNotification>(
|
||||||
onNotification: (notification) {
|
onNotification: (notification) {
|
||||||
if (notification is ScrollUpdateNotification) {
|
if (notification is ScrollUpdateNotification) {
|
||||||
setState(() {
|
final newOffset = notification.metrics.pixels;
|
||||||
_scrollOffset = 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;
|
return false;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user