I want to scroll down with the press of a Button, exactly the current screen height.
I already tried this Flutter: Scrolling to a widget in ListView but it doesn't help much.
I am using a SingleChildScrollView()
inside a Scaffold
.
I want to scroll down with the press of a Button, exactly the current screen height.
I already tried this Flutter: Scrolling to a widget in ListView but it doesn't help much.
I am using a SingleChildScrollView()
inside a Scaffold
.
Create a ScrollController
.
final _controller = ScrollController();
Your callback.
void _onPressed() {
// Get the height you want to scroll to.
final screenHeight = MediaQuery.of(context).size.height;
// If you don't want any animation, use this:
_controller.jumpTo(screenHeight);
// Otherwise use this:
_controller.animateTo(screenHeight, curve: Curves.easeOut, duration: Duration(seconds: 1));
}
Your SingleChildScrollView
:
SingleChildScrollView(
controller: _controller,
child: ...,
)