Cant scroll within pageview widget in flutter

49 Views Asked by At

I have a pageview in flutter, and each page view has a list of cards that I would like to scroll vertically up and down.

Currently I can scroll left and right to go between the different pageviews and see wach different list of cards.

But I can not scroll within the list of cards on any pageview

PageView(
        controller: swipeController,
        children: [
          //Conditions Cards for sun/clouds and rain probability
          Consumer<Settings>(
            builder: (context, weatherList, child) {
              return ListView.builder(
                physics: NeverScrollableScrollPhysics(),
                itemCount: weatherList.weatherLocations.length,
                itemBuilder: (context, index) {
                  return WeatherCard(
                    lat: weatherList.weatherLocations[index].lat,
                    long: weatherList.weatherLocations[index].lng,
                    name: weatherList.weatherLocations[index].formattedAddress,
                    forcastType: 'conditions',
                    lastUpdate: weatherList.weatherLocations[index].lastUpdate,
                  );
                },
              );
            },
          ),
          //todo: Temperature Cards
          Consumer<Settings>(
            builder: (context, weatherList, child) {
              return ListView.builder(
                physics: NeverScrollableScrollPhysics(),
                itemCount: weatherList.weatherLocations.length,
                itemBuilder: (context, index) {
                  return WeatherCard(
                    lat: weatherList.weatherLocations[index].lat,
                    long: weatherList.weatherLocations[index].lng,
                    name: weatherList.weatherLocations[index].formattedAddress,
                    forcastType: 'temperature',
                    lastUpdate: weatherList.weatherLocations[index].lastUpdate,
                  );
                },
              );
            },
          ),
          Consumer<Settings>(
            builder: (context, weatherList, child) {
              return ListView.builder(
                physics: NeverScrollableScrollPhysics(),
                itemCount: weatherList.weatherLocations.length,
                itemBuilder: (context, index) {
                  return WeatherCard(
                    lat: weatherList.weatherLocations[index].lat,
                    long: weatherList.weatherLocations[index].lng,
                    name: weatherList.weatherLocations[index].formattedAddress,
                    forcastType: 'windSpeed',
                    lastUpdate: weatherList.weatherLocations[index].lastUpdate,
                  );
                },
              );
            },
          ),
        ],
      ),

I have tried addign a single child scrollview to each listview builder but I thought each listview builder should be its own scrollabel list so I am a bit confused.

1

There are 1 best solutions below

1
On

you can solve the issue by removing this property :

physics: NeverScrollableScrollPhysics() 

code:

Consumer<Settings>(
         builder: (context, weatherList, child) {
              return ListView.builder(
                itemCount: weatherList.weatherLocations.length,
                itemBuilder: (context, index) {
                  return WeatherCard(
                    lat: weatherList.weatherLocations[index].lat,
                    long: weatherList.weatherLocations[index].lng,
                    name: weatherList.weatherLocations[index].formattedAddress,
                    forcastType: 'conditions',
                    lastUpdate: weatherList.weatherLocations[index].lastUpdate,
                  );
                },
              );
            },
          ),