flutter blank page in page view

Issue

my page view

I have this page view in flutter and I get a blank page on the first page, how to solve this problem?

          PageView.builder(
              physics: new NeverScrollableScrollPhysics(),
              itemCount: allDays.length,
              controller: _pageController,
              itemBuilder: ( context, int index) {
                return index == 0 ? Container() : _listDay(index-1);
              },
            )

Solution

In the itemBuilder, you are returning an empty Container for index 0. As the index is zero-based, index 0 is the first page. Try the following:

  PageView.builder(
      physics: new NeverScrollableScrollPhysics(),
      itemCount: allDays.length,
      controller: _pageController,
      itemBuilder: ( context, int index) {
        return _listDay(index);
      },
    )

Answered By – Josh

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

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