Flutter PageView Widget To Create Swipeable View in Android iOS

PageView widget in flutter is used to make Swipeable widget list. PageView widget support both Vertical and Horizontal swipeable scrolling. In PageView widget each child widget should be in same as Parent View port. If your parent widget size is full screen then it will make the swipeable widgets full screen. So in this tutorial we would Flutter PageView Widget To Create Swipeable View in Android iOS Example Tutorial.

Contents in this project Flutter PageView Widget To Create Swipeable View in Android iOS Example Tutorial:

1. Import material.dart package in your app’s main.dart file.

2. Create void main runApp() method and here we would call our main Root MyApp class.

3. Create our main Root View class named as MyApp extends with StatelessWidget. In this class we would call the Page class.

4. Create a class named as Page extends with StatefulWidget. In this class we would call the createState() method of State and define the PageState class along with it.

5. Create a class named as PageState extends with State.

6. Create a PageController with initial Page value as Zero. Here Zero is our Index page widget number. Using this we can decide which widget should display first on app starts.

7. Create Widget Build area in PageState class. Now we would make Scaffold widget -> Center Widget.

8. Creating PageView widget in Center widget with 3 Child Container widget.

  • controller : Used to control which widgets displays first on screen.
  • onPageChanged : Calls every time when Widgets changes in PageView.
  • pageSnapping : To enable and disable page snapping.
  • scrollDirection : Used to make scrolling in horizontal and Vertical direction.

9. Complete source code for main.dart file:

Screenshots:

Flutter PageView Widget To Create Swipeable View in Android iOS

Flutter PageView Widget To Create Swipeable View in Android iOS

Leave a Reply

Your email address will not be published. Required fields are marked *