Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append new ListView items at the top

I am fetching ListView.builder() items from Cloud Firestore inside a StreamBuilder. I want the new item to be added at the top of the ListView. How can I do that? I tried reverse : true , though it reverse the ListView, but when there is only 2/3 items, the ListView looks ugly, as the ListView starts from bottom and the upper portion of the screen remains empty.

like image 270
Newaj Avatar asked Jan 20 '26 05:01

Newaj


1 Answers

Added shrinkWrap: true and put the ListView inside an Align widget with alignment: Alignment.topCenter and got the result I wanted!

              Align(
                alignment: Alignment.topCenter,
                child: ListView.builder(
                  reverse: true,
                  shrinkWrap: true,
                  ...
                  ...
               )
             )
like image 87
Newaj Avatar answered Jan 23 '26 19:01

Newaj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!