Home > Software engineering >  Column elements are not scrollable in flutter
Column elements are not scrollable in flutter

Time:07-18

I also tried to wrap the second column in SingleChildScrollView but that didn't work either. Please tell me a solution. The screen is not scrolling. When I delete the upper element only then other comes. Here is my code.

   SingleChildScrollView(
              child: Column(
                children: [
                  Padding(
                    padding: EdgeInsets.only(left: 16.0, right: 16.0),
                    child: FutureBuilder(
                      future: getAppointments(email),
                      builder: (context, AsyncSnapshot snapshot) {
                        if (snapshot.hasData) {
                          return ListView.builder(
                              scrollDirection: Axis.vertical,
                              shrinkWrap: true,
                              itemCount: snapshot.data.length,
                              itemBuilder: (_, index) {
                                AppointmentsUser appointments =
                                    snapshot.data[index];
    
                                return Column(children: <Widget>[
                                  ListTile(
                                    title: Text(
                                      appointments.service,
                                      style: TextStyle(fontSize: 20),
                                    ),
                                    leading: Icon(
                                      Icons.people,
                                    ),
                                  ),
                                  ListTile(
                                    title: Text("Seller: ${appointments.seller}"),
                                  ),
                                  ListTile(
                                    title: Text("Date: ${appointments.date}"),
                                  ),
                                  ListTile(
                                    title: Text("Time: ${appointments.time}"),
                                  ),
                                  Divider(),
                                ]);
                              });
                        } 
                        return CircularProgressIndicator.adaptive();
                      },
                    ),
                  ),
                ],
              ),
            ),
          ),
        );

CodePudding user response:

The issue is that list view also has a scroll and single child scroll view also has a scroll. Removing either one should let you scroll through the content. You can either add a NeverScrollableScrollPhysics tolistview or remove SingleChildScrollView since list view has got a scroll by default

ListView.builder(
    physics: NeverScrollableScrollPhysics(),//add this line
    scrollDirection: Axis.vertical,
    shrinkWrap: true,
....

CodePudding user response:

ListView.builder(
    scrollDirection: Axis.vertical,
    shrinkWrap: true,
    primary: false,// <=== add this line
...

CodePudding user response:

Just simply add this , it works fine from my side.

SingleChildScrollView( physics: new NeverScrollableScrollPhysics(),
........ ),

  • Related