2

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
  • please post more complete code, what is WorkoutWidget() ? Commented Dec 25, 2021 at 15:19

1 Answer 1

0

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,
              );
            }),
      ),
    ],
  ),
),
Sign up to request clarification or add additional context in comments.

2 Comments

I get that exception now... The following RenderObject was being processed when the exception was fired: RenderFlex#e78dd relayoutBoundary=up16 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: creator: Column ← ColoredBox ← Padding ← Container ← _SingleChildViewport ← IgnorePointer-[GlobalKey#7145d] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#b7d52] ← Listener ← _ScrollableScope ← ⋯
Ok, it would be great if you could give us a complete dart file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.