-
Notifications
You must be signed in to change notification settings - Fork 13
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
How to prevent overscrolling of screen even if there's a not so much of elements in viewport? #6
Comments
+1 for this. This is a small, but quite noticeable behaviour that native iOS has. |
Did anyone find a solution for this? |
Not a solution, but a workaround. Create a final ScrollController _scrollController = ScrollController();
/// These are arbitrary values
/// Edit this method according to your needs
void _fixOverscroll() {
if (_scrollController.hasClients) {
if (_itemCount <= 1) {
if (_scrollController.offset > 0) {
_scrollController.jumpTo(0);
}
} else if (_itemCount <= 2) {
if (_scrollController.offset > 60) {
_scrollController.jumpTo(60);
}
} else if (_itemCount <= 3) {
if (_scrollController.offset > 180) {
_scrollController.jumpTo(180);
}
}
}
}
@override
void initState() {
super.initState();
_scrollController.addListener(_fixOverscroll);
}
@override
void dispose() {
_scrollController.removeListener(_fixOverscroll);
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// stuff
} |
+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've made small explanation of what I have and what I'm expecting
IMG_0210.MP4
here's the code of actual Example Widget:
The text was updated successfully, but these errors were encountered: