Reputation: 451
I've created a ListView
without any padding
or margin
. But the ListView
was separated with empty space like this one:
And this is my code of this ListView
:
content: Container(
width: context.widthPct(.5),
height: context.heightPct(.4),
child: CupertinoScrollbar(
child: ListView(
children: [
Center(
child: Image.asset("assets/logo_horizontal.png"),
),
Align(
alignment: Alignment.topCenter,
child: Text(
"Sumber data doa :\nApa Doanya app\n\nTerima kasih sudah\nmenggunakan Moodo :D\n\nš nabilrei š\nš hantsnm š\nš rennyatikas š\nš§ cayne.dameron š§\n",
style: Style().body,
textAlign: TextAlign.center,
),
),
Center(
child: Text(
"versi 1.0.0",
style: Style(styleColor: Colors.grey.shade600).body,
),
),
],
),
),
),
So, how can I remove empty space at the top of this ListView?
Upvotes: 13
Views: 12911
Reputation: 201
ListView.builder(
padding: EdgeInsets.zero,
itemCount: 30,
itemBuilder: (context, index) {
return Text(
'Job Type',
);
},
),
Upvotes: 3
Reputation: 11
MediaQuery.removePadding( context: context, removeTop: true, child: ListView
It will work for builder also
Upvotes: 0
Reputation: 545
Set padding to zero
ListView(
padding: const EdgeInsets.zero,
itemBuilder: ...,
itemCount: ...
);
Or control padding in listview
ListView(
padding: const EdgeInsets.only(top: 20),
itemBuilder: ...,
itemCount: ...
);
Upvotes: 3
Reputation: 5098
Listview has default padding, you can change it by specifying your required EdgeInsets. To remove padding use EdgeInsets.zero
ListView(
padding: EdgeInsets.zero,
children: [],
);
Upvotes: 36
Reputation: 7601
Try
MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView
Upvotes: 27