Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It doesn't work when use a center key in CustomScrollView - Used for bidirectional list #91

Open
MiniSuperDev opened this issue May 12, 2022 · 3 comments

Comments

@MiniSuperDev
Copy link

Hi, I try to create a bidirectional lazy load list like the like flutter docs said
https://github.com/flutter/flutter/blob/5464c5bac742001448fe4fc0597be939379f88ea/packages/flutter/lib/src/widgets/scroll_view.dart#L502-L513

I create a gist where you can enable a disable the center key, and you can see that only highlight work, but the scrollTo not work when the center key is enable.

how can I keep the scroll to index behavior while have the center key? or maybe do you know other way to create a list that append items to the top of the list by preserving the scroll, the solution that I used is from flutter/flutter#21541 (comment)

thank you

@1203556555
Copy link

I also encountered this problem. Have you found any solutions? @MiniSuperDev

@yunhe-lin
Copy link

AutoScrollControllerMixin:

while (prevOffset != currentOffset &&
!(contains = isIndexStateInLayoutRange(index))) {
prevOffset = currentOffset;
final nearest = _getNearestIndex(index);
final moveTarget =
_forecastMoveUnit(index, nearest, usedSuggestedRowHeightIfAny)!;
if (moveTarget < 0) //can't forecast the move range
return null;
// assume suggestRowHeight will move to correct offset in just one time.
// if the rule doesn't work (in variable row height case), we will use backup solution (non-suggested way)
final suggestedDuration =
usedSuggestedRowHeightIfAny && suggestedRowHeight != null
? duration
: null;

remove
if (moveTarget < 0) //can't forecast the move range
return null;
is useful

@khomin
Copy link

khomin commented Jul 29, 2023

AutoScrollControllerMixin:

while (prevOffset != currentOffset && !(contains = isIndexStateInLayoutRange(index))) { prevOffset = currentOffset; final nearest = _getNearestIndex(index); final moveTarget = _forecastMoveUnit(index, nearest, usedSuggestedRowHeightIfAny)!; if (moveTarget < 0) //can't forecast the move range return null; // assume suggestRowHeight will move to correct offset in just one time. // if the rule doesn't work (in variable row height case), we will use backup solution (non-suggested way) final suggestedDuration = usedSuggestedRowHeightIfAny && suggestedRowHeight != null ? duration : null;

remove if (moveTarget < 0) //can't forecast the move range return null; is useful

there is even no such code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants