How to create infinity PageView in Flutter


How to create an PageView which are supported circle scroll in Flutter? That’s mean when I stand on 0 page, I could scroll to left to the last page.

Updated: I answered this question and update a gist source also.


I found a solution here. I create a CustomScrollView with 2 slivers. One for go forward, one for go back. However, I have to calculate if my list short.

typedef Widget Builder(BuildContext buildContext, int index);

class InfiniteScrollView extends StatefulWidget {
  final Key center = UniqueKey();
  final Builder builder;
  final int childCount;

      {Key key, @required this.builder, @required this.childCount})
      : super(key: key);

  _InfiniteScrollViewState createState() => _InfiniteScrollViewState();

class _InfiniteScrollViewState extends State<InfiniteScrollView> {
  Widget build(BuildContext context) {
    return Container(
      child: CustomScrollView(
        scrollDirection: Axis.horizontal,
        slivers: <Widget>[
            delegate: SliverChildBuilderDelegate(
              (BuildContext context, int index) => widget.builder(
                  context, widget.childCount - index % widget.childCount - 1),
            delegate: SliverChildBuilderDelegate(widget.builder),

Updated: I write a new widget which support infinity TabBar.

Answered By – Trần Đức Tâm

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *