Flutter: How to scroll page with onTap or onPressed

Viewed 1647

I am creating a website with Flutter Web, and I want to navigate down in the screen with onTap on top Navbar. Like we do it in web development which will navigate to a specific id.

How can I achieve this?

Can we use ScrollController?

EDIT: I found the solution here: https://stackoverflow.com/a/58924800/11545939

1 Answers

You should use ScrollController like this:

EDIT

var _scrollController = ScrollController();

void goUp(){
    _scrollController.animateTo(
      0.0,
      duration: Duration(milliseconds: 500),
      curve: Curves.easeInOutQuart,
    );
}

@override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        physics: PageScrollPhysics(),
        controller: _scrollController,
Related