Flutter : How to remove empty space at the top of ListView

Viewed 2084

I've created a ListView without any padding or margin. But the ListView was separated with empty space like this one: enter image description here

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? Thank you :)

3 Answers

Try

MediaQuery.removePadding(
        context: context,
        removeTop: true,
        child: ListView

Listview has default padding, you can change it by specifying your required EdgeInsets. To remove padding use EdgeInsets.zero

ListView(
padding: EdgeInsets.zero,
children: [],
);

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: ...
);
Related