问题
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