Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 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.  
  31. _sameUser() ?
  32. new Icon(
  33. Icons.account_circle
  34. )
  35. :
  36. Container()
  37.  
  38.  
  39. bool _sameUser () {
  40. assert(index >= 0);
  41. assert(map != null);
  42. return map[index + 1] != null && map[index + 1]['fromUser'] == map[index]['fromUser'];
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement