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:
Page View
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
Navigate to Variables in your project
Click Add Variable
Select Page Controller as the type
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
jumpToPageInstantly switches to a specific page without animation.
page
Number
The target page index (zero-based)
Example Use Cases:
Jump to first page:
page: 0Jump to last page:
page: 2Jump to specific page:
page: 1
When to Use:
Immediate page changes (e.g., reset to first page)
No animation needed
Faster than
animateToPage
animateToPage
animateToPageSmoothly animates the transition to a specific page.
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 speedeaseIn- Slow start, fast endeaseOut- Fast start, slow endeaseInOut- Slow start and end, fast middlebounceOut- Bouncing effect at endelasticOut- 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
nextPageAnimates to the next page.
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
previousPageAnimates to the previous page.
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:
2. Image Gallery with Indicators
Create an image gallery with page indicators.
Setup:
Page Indicator:
3. Custom Tab Navigation
Implement a tab-based interface using PageView.
4. Auto-Advancing Carousel
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
easeInOutfor most page transitionsSet 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
animateToPagewith calculated indices for sequential navigationReset 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
Related Documentation
Page View - PageView widget reference
Animation Builder - Create page-driven animations
Control Object Action - Invoke controller methods
Variables Overview - Learn about all variable types
Last updated