0

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);
              },
            )
dan1st
  • 12,568
  • 8
  • 34
  • 67
Husamuldeen
  • 439
  • 1
  • 8
  • 21

1 Answers1

0

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);
      },
    )
Josh
  • 991
  • 6
  • 14
  • that's worked dear, the widget was list view and i convert it to the page view, can you help me with this too? https://stackoverflow.com/questions/60277469/how-to-make-day-and-time-list-horizontal-view-from-api-with-two-button-to-scroll – Husamuldeen Feb 27 '20 at 08:52