Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. class MainState extends State<Main> {
  2.  
  3. final Map<int, dynamic> map = {};
  4.  
  5. body: FirestoreAnimatedList(
  6. query: firestore.collection('messages').snapshots(),
  7. itemBuilder: (
  8. BuildContext context,
  9. DocumentSnapshot snapshot,
  10. Animation<double> animation,
  11. int index,
  12. ) {
  13.  
  14. map[index] = snapshot;
  15.  
  16. return FadeTransition(
  17. opacity: animation,
  18. child: MessageItem(
  19. index: index,
  20. document: snapshot,
  21. map: map,
  22. ),
  23. );
  24. },
  25.  
  26.  
  27. class MessageItem extends StatelessWidget {
  28.  
  29.  
  30. @override
  31. Widget build(BuildContext context) {
  32. return Container(
  33. child: new Row(
  34. children: <Widget>[
  35. new Container(
  36. child:
  37.  
  38. _sameUser() ?
  39. new Icon(
  40. Icons.account_circle
  41. )
  42. : Container()
  43.  
  44. bool _sameUser () {
  45. assert(index >= 0);
  46. assert(map != null);
  47. return map[index + 1] != null && map[index + 1]['fromUser'] == map[index]['fromUser'];
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement