João Pedro
João Pedro

Reputation: 960

Can't scroll ListView when child expands height

I have a ListView.builder that renders a list of Containers who can expand in height when the user clicks on it ( I'm using AnimatedSize to wrap the Containers), however I noticed that when the Container is expanded I can't scroll the ListView by pressing and dragging around the expanded area, only in the area that Container occupied originally.

 ListView.builder(
                        physics: AlwaysScrollableScrollPhysics(),
                        itemCount: profilesList.profilesCount,
                        shrinkWrap: true,
                        scrollDirection: Axis.vertical,
                        itemBuilder: (context, index) {
                          return ProfileBar(
                              id: profilesList.profiles[index].id!,
                              index: index,
                              name: profilesList.profiles[index].name,
                              emoji: profilesList.profiles[index].emoji,
                              gender: profilesList.profiles[index].gender,
                              color: profilesList.profiles[index].color,
                              height: profilesList.profiles[index].height,
                              birthday: profilesList.profiles[index].birthday,
                              isSelected: profilesList.selectedProfileID ==
                                  profilesList.profiles[index].id,
                              onSelect: (_) async {
                                profilesList.selectProfile(
                                    profilesList.profiles[index].id!);
                                    Provider.of<GoalModel>(context, listen: false).getGoal(profilesList.profiles[index].id!);
                                await UserSettings.setProfile(
                                    profilesList.profiles[index].id!);
                                _getRecords(context);
                              });
                        },
                      ),

Is there a way to fix this?

Upvotes: 0

Views: 47

Answers (2)

Jo&#227;o Pedro
Jo&#227;o Pedro

Reputation: 960

So I found my problem is that my list item had a GridView widget, I changed the physics to NeverScroll and fixed it.

Upvotes: 0

Hardik Mehta
Hardik Mehta

Reputation: 2425

Wrap that Listview with SingleChildScrollView and add physics : NeverScrollableScrollPhysics() to Listview and check.

Upvotes: 2

Related Questions