Created
May 24, 2020 23:38
-
-
Save huxaiphaer/1585c1d9145ce6cd7d46c29bc369a008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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