flutter

Unexpected space inside Flutter Column widget


I'm writing code inside a column, but I have an unexpected size. I think it's from a margin, but I don't know where it is coming from.

How can I find and remove this?

Column(
      children: [
        Text("test"),
        // Here some margin, why ?
        Container(
          height: 200,
          child: ListView.builder(
            shrinkWrap: true,
            itemCount: answers.length,
            itemBuilder: (BuildContext context, int index) {
              return Text(answers[index]);
            }
          ),
        )
      ],
    );

enter image description here

I tried to put SizedBox instead of my Container but not work. Maybe it's normal?

I tried to remove SizedBox or Container, to get only my ListView, but this blank is always here.

Here is Flutter Inspector:
The 20 height with green border is the Text "test" before the List enter image description here


Solution

  • It might the default padding of ListView. You could try

    ListView.builder(
      padding: EdgeInsets.zero,
      itemBuilder: (BuildContext context, int index) {
        return Text("answers[$index]");
      }),
    )