Site icon Flutter Packages | Pub dev Packages – Flutter Mobile App World

Infinite View Pager widget for Flutter

infinite_view_pager

Flutter infinite view pager widget

Installation

dependencies:
  infinite_view_pager: ^1.0.0

Example

import 'package:infinite_view_pager/infinite_view_pager.dart';

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: InfiniteViewPager(
        onPageChanged: (direction) {
          index += direction;
        },
        pageBuilder: _buildPage,
        scrollDirection: Axis.vertical,
      ),
    );
  }
}

Author

MIT

Download Source code of Flutter Infinite View Pager widget on GitHub

https://github.com/lesnitsky/infinite_view_pager

Exit mobile version