flutterswipe-gesture

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.

chrome side swipe


Solution

  • 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