infinite_view_pager

Flutter infinite view pager widget

GitHub stars Twitter Follow

Demo

Installation

dependencies:
  infinite_view_pager: ^1.0.0

Example

class InfiniteViewPagerDemo extends StatefulWidget {
  @override
  _InfiniteViewPagerDemoState createState() => _InfiniteViewPagerDemoState();
}

class _InfiniteViewPagerDemoState extends State<InfiniteViewPagerDemo> {
  int index = 0;

  Widget _buildPage(BuildContext context, int direction) {
    return Container(
      padding: EdgeInsets.all(100.0),
      child: Card(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(20.0),
        ),
        elevation: 10,
        child: Center(
          child: Text(
            (index + direction).toString(),
            style: Theme.of(context).textTheme.display4,
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: InfinitePageView(
        onPageChanged: (direction) {
          index += direction;
        },
        pageBuilder: _buildPage,
        scrollDirection: Axis.vertical,
      ),
    );
  }
}

Author

Andrei Lesnitsky

License

MIT

GitHub stars Twitter Follow

Libraries

infinite_view_pager