I was wondering when using SingleChildScrollView
, is there a way to stop scrolling either up or down when for example the page is already at the top, so I would like to prevent the page from keep scrolling up for example. Because I don't want to change the background of the entire Scaffold
but when scrolling above the top, there's the white Scaffold
background color showing, and it does not look that great. Thank you! The code is not something too fancy, eg.
return SingleChildScrollView(
child: Container(
width: 200,
height: 2000,
color: Colors.red,
),
);
This is what what it shows when keep scrolling up when already at the top
Adding ClampingScrollPhysics()
to your SingleChildScrollView will do the trick,
return SingleChildScrollView(
physics : ClampingScrollPhysics(),
child: Container(
width: 200,
height: 2000,
color: Colors.red,
),
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.