Page Controller

A Page Controller is a special variable type that manages navigation and animation between pages in a PageView widget. It allows you to programmatically switch pages, create page-based animations, and build features like onboarding flows or image galleries.

Supported Widgets

The Page Controller can be used with:

When to Use

Use a Page Controller when you need to:

  • Build onboarding or tutorial flows

  • Create image galleries or carousels

  • Implement tab-based navigation

  • Programmatically navigate between pages

  • Create page-driven animations

  • Track current page index

  • Implement custom page indicators

Creating a Page Controller

  1. Navigate to Variables in your project

  2. Click Add Variable

  3. Select Page Controller as the type

  4. Give it a descriptive name (e.g., onboardingController, galleryController)

Binding to Widgets

PageView Example

Animation Builder Example

Create page-driven animations:

Controller Methods

Use the Control Object action to invoke these methods on the controller.

jumpToPage

Instantly switches to a specific page without animation.

Parameter
Type
Description

page

Number

The target page index (zero-based)

Example Use Cases:

  • Jump to first page: page: 0

  • Jump to last page: page: 2

  • Jump to specific page: page: 1

When to Use:

  • Immediate page changes (e.g., reset to first page)

  • No animation needed

  • Faster than animateToPage


animateToPage

Smoothly animates the transition to a specific page.

Parameter
Type
Description

page

Number

The target page index (zero-based)

durationInMs

Number

Animation duration in milliseconds

curve

String

The easing curve for animation

Available Curves:

  • linear - Constant speed

  • easeIn - Slow start, fast end

  • easeOut - Fast start, slow end

  • easeInOut - Slow start and end, fast middle

  • bounceOut - Bouncing effect at end

  • elasticOut - Elastic spring effect

Example Use Cases:

  • Smooth page transition: page: 1, durationInMs: 400, curve: 'easeInOut'

  • Quick flip: page: 2, durationInMs: 200, curve: 'linear'

  • Bouncy effect: page: 0, durationInMs: 600, curve: 'bounceOut'

When to Use:

  • Better UX with smooth transitions

  • User-triggered navigation

  • Highlighting the page change


nextPage

Animates to the next page.

Parameter
Type
Description

durationInMs

Number

Animation duration in milliseconds

curve

String

The easing curve for animation

Example:

When to Use:

  • "Next" or "Continue" buttons

  • Sequential navigation flows

  • Automatic page advancement


previousPage

Animates to the previous page.

Parameter
Type
Description

durationInMs

Number

Animation duration in milliseconds

curve

String

The easing curve for animation

Example:

When to Use:

  • "Back" or "Previous" buttons

  • Reverse navigation

  • Undo-like interactions


Common Use Cases

1. Onboarding Flow

Create a multi-step onboarding with navigation controls.

Setup:

Navigation:

Create an image gallery with page indicators.

Setup:

Page Indicator:

3. Custom Tab Navigation

Implement a tab-based interface using PageView.

Create a carousel that automatically advances.

5. Conditional Navigation

Navigate based on conditions (e.g., skip pages based on user input).

Best Practices

  • Track current page: Store the current page index in a variable to enable conditional logic

  • Use descriptive names: Name controllers after their purpose (onboardingController, galleryController)

  • Choose appropriate curves: Use easeInOut for most page transitions

  • Set reasonable durations: 300-500ms works well for page animations

  • Handle edge cases: Disable "next" on last page, "previous" on first page

  • Use nextPage/previousPage: Prefer these over animateToPage with calculated indices for sequential navigation

  • Reset on navigation: Jump to page 0 when entering/exiting flows

Common Patterns

Next Button with Validation

Conditional Back Button

Skip to End

Page Indicator Dots

Troubleshooting

Controller Not Working

  • Ensure the controller variable is properly created

  • Check that the controller is bound using ${controllerName}

  • Verify the widget supports Page Controller

Page Index Out of Bounds

  • Check that page indices are within valid range (0 to pageCount - 1)

  • Handle edge cases for first and last pages

Animation Feels Choppy

  • Reduce animation duration

  • Use simpler easing curves

  • Optimize page content for better performance

Last updated