Search code examples
androidflutterdartscroll

Column elements are not scrollable in flutter


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 another 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();
          },
        ),
      ),
    ],
  ),
),

Solution

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

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