A highly customizable, performant Flutter PageView widget where pages slide smoothly over one another cleanly without multi-page overlap visual glitches during fast swipes. Includes lazy loading support (OverlapPageView.builder), dedicated OverlapPageController, and full support for viewportFraction.
| Horizontal Overlay Scroll | Vertical Overlay Scroll |
|---|---|
![]() |
![]() |
- 🎨 Overlay & Parallax Effects: Cleanly slide incoming pages on top of preceding pages with customizable behind behavior (
stationary,parallax,normal). - ⚡ Lazy Loading (
OverlapPageView.builder): Builds pages on demand as they are navigated/scrolled to, avoiding unnecessary initial builds. - 🎮 Dedicated Controller: Comes with
OverlapPageController(extendingPageController) for seamless page navigation (nextPage,previousPage,animateToPage,jumpToPage). - 📐 Viewport Fraction Support: Full support for
viewportFractionboth viaOverlapPageControllerand directly onOverlapPageView.builder. - 🔄 Multi-Directional: Supports both
Axis.horizontalandAxis.verticalscroll directions. - 🔍 Depth & Fade Animations: Optional depth scaling (
enableDepthScale,minScale) and smooth opacity fading (enableFade). - 💾 State Preservation: Built-in
wantKeepAlivesupport to retain page widget state across swipes once loaded.
import 'package:flutter/material.dart';
import 'package:overlay_page_view/overlap_page_view/overlap_page_view.dart';
class MyOverlapDemo extends StatefulWidget {
const MyOverlapDemo({super.key});
@override
State<MyOverlapDemo> createState() => _MyOverlapDemoState();
}
class _MyOverlapDemoState extends State<MyOverlapDemo> {
final OverlapPageController _controller = OverlapPageController(
initialPage: 0,
viewportFraction: 1.0,
);
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: OverlapPageView.builder(
controller: _controller,
behindBehavior: OverlapBehindBehavior.parallax,
parallaxFactor: 0.25,
wantKeepAlive: true,
scrollDirection: Axis.horizontal,
itemCount: 3,
itemBuilder: (context, index) {
switch (index) {
case 0:
return Container(color: Colors.deepPurple, child: const Center(child: Text('Page 1')));
case 1:
return Container(color: Colors.indigo, child: const Center(child: Text('Page 2')));
case 2:
return Container(color: Colors.teal, child: const Center(child: Text('Page 3')));
default:
return null;
}
},
),
);
}
}| Parameter | Type | Default | Description |
|---|---|---|---|
itemBuilder |
NullableIndexedWidgetBuilder |
Required | Lazy builder callback to construct page widgets on demand. |
itemCount |
int |
Required | Total number of pages in the page view. |
controller |
PageController? |
null |
Controller for the page view (OverlapPageController or PageController). |
initialPage |
int |
0 |
Initial page index if no controller is provided. |
viewportFraction |
double |
1.0 |
Fraction of the viewport occupied by each page. |
behindBehavior |
OverlapBehindBehavior |
.stationary |
Defines how the page behind behaves (stationary, parallax, normal). |
parallaxFactor |
double |
0.25 |
Parallax factor (0.0 to 1.0) when behindBehavior is parallax. |
enableDepthScale |
bool |
true |
Enables shrinking scale effect on covered pages. |
minScale |
double |
0.9 |
Minimum scale factor for covered pages. |
enableFade |
bool |
true |
Enables opacity fade on covered pages. |
wantKeepAlive |
bool |
false |
Retains page widget state in memory once loaded across swipes. |
scrollDirection |
Axis |
Axis.horizontal |
Scroll direction (Axis.horizontal or Axis.vertical). |
physics |
ScrollPhysics? |
null |
Custom scroll physics. |
OverlapPageController extends Flutter's standard PageController, so it supports all standard page manipulation methods:
// Move to next page
_controller.nextPage(
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
);
// Jump to specific page
_controller.jumpToPage(2);
// Animate to specific page
_controller.animateToPage(
1,
duration: const Duration(milliseconds: 500),
curve: Curves.easeOutCubic,
);This project is licensed under the MIT License - see the LICENSE file for details.

