Skip to content

Commit b4867c2

Browse files
committed
feat(NestedScrollUtil): add await support for animateTo and jumpTo methods
1 parent 664964b commit b4867c2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/src/utils/src/nested_scroll_util.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class NestedScrollUtil {
131131
}
132132

133133
/// Jump to the specified index position.
134-
jumpTo({
134+
Future jumpTo({
135135
required GlobalKey nestedScrollViewKey,
136136
required SliverObserverController observerController,
137137
required NestedScrollUtilPosition position,
@@ -145,14 +145,14 @@ class NestedScrollUtil {
145145
}) {
146146
assert(outerScrollController != null, 'outerScrollController is null');
147147
assert(bodyScrollController != null, 'bodyScrollController is null');
148-
if (outerScrollController == null) return;
149-
if (bodyScrollController == null) return;
148+
if (outerScrollController == null) return Future.value();
149+
if (bodyScrollController == null) return Future.value();
150150
switchScrollController(
151151
observerController: observerController,
152152
position: position,
153153
);
154154

155-
observerController.jumpTo(
155+
return observerController.jumpTo(
156156
index: index,
157157
sliverContext: sliverContext,
158158
isFixedHeight: isFixedHeight,
@@ -170,7 +170,7 @@ class NestedScrollUtil {
170170
}
171171

172172
/// Animate to the specified index position.
173-
animateTo({
173+
Future animateTo({
174174
required GlobalKey nestedScrollViewKey,
175175
required SliverObserverController observerController,
176176
required NestedScrollUtilPosition position,
@@ -186,14 +186,14 @@ class NestedScrollUtil {
186186
}) {
187187
assert(outerScrollController != null, 'outerScrollController is null');
188188
assert(bodyScrollController != null, 'bodyScrollController is null');
189-
if (outerScrollController == null) return;
190-
if (bodyScrollController == null) return;
189+
if (outerScrollController == null) return Future.value();
190+
if (bodyScrollController == null) return Future.value();
191191
switchScrollController(
192192
observerController: observerController,
193193
position: position,
194194
);
195195

196-
observerController.animateTo(
196+
return observerController.animateTo(
197197
index: index,
198198
duration: duration,
199199
curve: curve,

0 commit comments

Comments
 (0)