Skip to content

Commit 15fdef6

Browse files
committed
fix: ScrollMetrics.minScrollExtent != 0.0, offset calculation error (#581).
1 parent 3e6b045 commit 15fdef6

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## V 3.0.4
2+
> fix: ScrollMetrics.minScrollExtent != 0.0, offset calculation error.
3+
> feat: Supported [ScrollView.center] [#581](https://github.com/xuelongqy/flutter_easy_refresh/pull/581).
4+
15
## V 3.0.3+1
26
> docs: NestedScrollView example.
37

example/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: EasyRefresh example.
77
# Both the version and the builder number may be overridden in flutter
88
# build by specifying --build-name and --build-number, respectively.
99
# Read more about versioning at semver.org.
10-
version: 3.0.3+48
10+
version: 3.0.4+49
1111

1212
environment:
1313
sdk: ">=2.13.0 <3.0.0"

lib/src/notifier/indicator_notifier.dart

+6-4
Original file line numberDiff line numberDiff line change
@@ -827,28 +827,30 @@ class HeaderNotifier extends IndicatorNotifier {
827827
!(clamping && _offset > 0)) {
828828
return 0;
829829
}
830+
// Moving distance
831+
final move = position.minScrollExtent - value;
830832
if (clamping) {
831833
if (value > position.minScrollExtent) {
832834
// Rollback first minus offset.
833-
return math.max(_offset > 0 ? (-value + _offset) : 0, 0);
835+
return math.max(_offset > 0 ? (move + _offset) : 0, 0);
834836
} else {
835837
// Overscroll accumulated offset.
836-
final mOffset = -value + _offset;
838+
final mOffset = move + _offset;
837839
if (hasSecondary && mOffset > secondaryDimension) {
838840
// Cannot exceed secondary offset.
839841
return secondaryDimension;
840842
}
841843
return mOffset;
842844
}
843845
} else {
844-
return value > position.minScrollExtent ? 0 : -value;
846+
return value > position.minScrollExtent ? 0 : move;
845847
}
846848
}
847849

848850
/// See [IndicatorNotifier.calculateOffsetWithPixels].
849851
@override
850852
double calculateOffsetWithPixels(ScrollMetrics position, double pixels) =>
851-
math.max(-pixels - position.minScrollExtent, 0.0);
853+
math.max(position.minScrollExtent - pixels, 0.0);
852854

853855
/// See [IndicatorNotifier.createBallisticSimulation].
854856
@override

lib/src/physics/scroll_physics.dart

-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ class _ERScrollPhysics extends BouncingScrollPhysics {
376376
}
377377
}
378378
}
379-
380379
// Update offset
381380
_updateIndicatorOffset(position, value, value);
382381
return bounds;

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: easy_refresh
22
description: A flutter widget that provides pull-down refresh and pull-up load.
3-
version: 3.0.3+1
3+
version: 3.0.4
44
homepage: https://xuelongqy.github.io/flutter_easy_refresh
55
repository: https://github.com/xuelongqy/flutter_easy_refresh
66
issue_tracker: https://github.com/xuelongqy/flutter_easy_refresh/issues

0 commit comments

Comments
 (0)