'How to start List View from top inside Stream Builder

I want to show a list of comments and so far i have achieve this

Code is as below:

body: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        mainAxisSize: MainAxisSize.max,
        children: [
          Expanded(
            child: CommentList(
              commentStream: commentBloc.commentStream!,
              articleId: widget.articleId!,
            ),
          ),
...

and the code for CommentList is:

return StreamBuilder<QuerySnapshot>(
      stream: commentStream,
      builder: (context, snapshot) {
        return snapshot.hasData && snapshot.data!.docs.length > 0
            ? ListView.builder(
                padding: EdgeInsets.only(bottom: 15.0),
                reverse: true,
                itemCount: snapshot.data!.docs.length,
                itemBuilder: (context, index) {
                  DocumentSnapshot ds = snapshot.data!.docs[index];
                  return CommentTile(
                    comment: ds["comment"],
                    commentterName: ds["commentedBy"],
                    timeAgo: ds["commentAt"],
                    avatar: ds["avatarUrl"],
                  );
                })
...

How i can achieve this ?



Solution 1:[1]

There is a reverse option inside the listview.builder() widget make it true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Viktor Ivliiev