Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MainState extends State<Main> {
- …
- final Map<int, dynamic> map = {};
- body: FirestoreAnimatedList(
- query: firestore.collection('messages').snapshots(),
- itemBuilder: (
- BuildContext context,
- DocumentSnapshot snapshot,
- Animation<double> animation,
- int index,
- ) {
- map[index] = snapshot;
- return FadeTransition(
- opacity: animation,
- child: MessageItem(
- index: index,
- document: snapshot,
- map: map,
- ),
- );
- },
- class MessageItem extends StatelessWidget {
- …
- @override
- Widget build(BuildContext context) {
- return Container(
- child: new Row(
- children: <Widget>[
- new Container(
- child:
- _sameUser() ?
- new Icon(
- Icons.account_circle
- )
- : Container()
- bool _sameUser () {
- assert(index >= 0);
- assert(map != null);
- return map[index + 1] != null && map[index + 1]['fromUser'] == map[index]['fromUser'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement