1

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.

Nuqo
  • 3,793
  • 1
  • 25
  • 37

1 Answers1

3

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: ...,
)
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440