简体   繁体   中英

Flutter swipe to sides like in chrome

In my book-like Flutter app, there is a requirement to swipe in horizontal direction in order to navigate to previous and next page. I looked for a package which does something like that in pub.dev and didn't find. I'd like to know if there is already something like that to not-invent a wheel. If not, I'd like to hear (not excepting you to make it for me) what approach can be taken in order to implement it by myself.

镀铬侧滑

What you're looking for is the PageView widget. Just provide the pages, the swiping functionality is built-in.

PageView(
  controller: _controller,
  children: [
    MyPage1Widget(),
    MyPage2Widget(),
    MyPage3Widget(),
  ],
)

Since you're saying it's for a book which likely has a lot of pages you might want to use PageView.builder() instead of better performance.

There's a more information about the widget here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM