Flutter: How to scroll page with onTap or onPressed [duplicate]

余生长醉 提交于 2021-01-27 18:39:06

问题


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:


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,


来源:https://stackoverflow.com/questions/61919334/flutter-how-to-scroll-page-with-ontap-or-onpressed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!