Skip to content

Instantly share code, notes, and snippets.

@huxaiphaer
Created May 24, 2020 23:38
Show Gist options
  • Save huxaiphaer/1585c1d9145ce6cd7d46c29bc369a008 to your computer and use it in GitHub Desktop.
Save huxaiphaer/1585c1d9145ce6cd7d46c29bc369a008 to your computer and use it in GitHub Desktop.
StreamBuilder(
stream: commentsStream,
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Container();
}
return GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
child: snapshot.data.documents.length != 0
? ListView.builder(
itemCount: snapshot.data.documents.length,
physics: AlwaysScrollableScrollPhysics(),
controller: _scrollController,
reverse: true,
itemBuilder: (context, index) {
return CommentsTile(
message: snapshot.data.documents[index].data["message"],
isAuthor: int.parse(snapshot
.data.documents[index].data["isAuthor"]
.toString()
.trim()) ==
0
? false
: true,
value: int.parse(snapshot
.data.documents[index].data["isAuthor"]
.toString()
.trim()),
name: snapshot.data.documents[index].data["username"],
date: formatDate(
snapshot.data.documents[index].data["time"]),
);
})
: Center(
child: Text(
"No comments",
style: TextStyle(
color: Colors.black,
fontSize: 15,
fontStyle: FontStyle.italic),
),
),
);
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment