Flutter listview scrolling is not available

Viewed 37

I can see 6 list items in my listview widget and I can not scroll the listview although 3 more items are there.

Actually I want to keep this workouts page pretty simple that means I want to avoid using many rows/columns...

I have just a text label at the top left corner and below listview.

What do I have to change to make the listview scrolling?

I already use physics: AlwaysScrollableScrollPhysics(),

   appBar: AppBar(
        title: Text(title),
      ),
      body: Container(
        color: Colors.green,
        margin: const EdgeInsets.all(5.0),
        child: Column(
          children: [
            Align(
              alignment: Alignment.topLeft,
              child: Text("Workouts", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)),
            ),
            Expanded(
              child: ListView.builder(
                  physics: AlwaysScrollableScrollPhysics(),
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  itemCount: workouts.length,
                  itemBuilder: (context, index) {
                    var workout = workouts[index];
                    return WorkoutWidget(key: Key(workout.id.toString()), workout: workout);
                  }),
            ),
          ],
        ),
      ),
1 Answers

Change physics to NeverScrollableScrollPhysics(), then wrap your Container with SingleChildScrollView widget. You could also omit scrollDirection, because Axis.vertical is already the default value.

appBar: AppBar(
  title: Text(title),
),
body: SingleChildScrollView(
  child: Container(
    color: Colors.green,
    margin: const EdgeInsets.all(5.0),
    child: Column(
      children: [
        Align(
          alignment: Alignment.topLeft,
          child: Text(
            "Workouts",
            style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25),
          ),
        ),
        Expanded(
          child: ListView.builder(
            physics: NeverScrollableScrollPhysics(),
            shrinkWrap: true,
            itemCount: workouts.length,
            itemBuilder: (context, index) {
              var workout = workouts[index];
              return WorkoutWidget(
                key: Key(workout.id.toString()), 
                workout: workout,
              );
            }),
      ),
    ],
  ),
),
Related