Search code examples
androidandroid-activityflutterswipe

Is it possible to open and close a new activity with swipe gesture in Flutter?


I want to open and close a new activity with Swipe gesture in a flutter in Android it can be done using libraries like Slidr but how can we achieve same in a flutter.

Click link to youtube video to get the idea about how it is done in Android.

Check the transition from one activity page to another


Solution

  • I would recommend using a PageView widget instead since you just want to detect left and right swipes.

    Example Code:

    PageView(
      controller : PageController(initialPage: 1)
      children: <Widget>[
        Container(color: Colors.red),//  1st Page (Left)
        Container(color Colors.blue),//  Default Current Page (2nd Page)
        Container(color: Colors.green), // 3rd Page (Right)
      ],
    )