Skip to content

About

High-performance Flutter PageView with smooth overlapping page transitions for modern card-stacking interfaces.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

OverlapPageView for Flutter

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.


Demos

Horizontal Overlay Scroll Vertical Overlay Scroll
Horizontal Overlay Demo Vertical Overlay Demo

Features

  • 🎨 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 (extending PageController) for seamless page navigation (nextPage, previousPage, animateToPage, jumpToPage).
  • 📐 Viewport Fraction Support: Full support for viewportFraction both via OverlapPageController and directly on OverlapPageView.builder.
  • 🔄 Multi-Directional: Supports both Axis.horizontal and Axis.vertical scroll directions.
  • 🔍 Depth & Fade Animations: Optional depth scaling (enableDepthScale, minScale) and smooth opacity fading (enableFade).
  • 💾 State Preservation: Built-in wantKeepAlive support to retain page widget state across swipes once loaded.

Getting Started

Basic Usage

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;
          }
        },
      ),
    );
  }
}

Properties

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.

Controllers

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,
);

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

High-performance Flutter PageView with smooth overlapping page transitions for modern card-stacking interfaces.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages