Я использую приложение случайного чата FirestoreAnimatedList
(FirebaseAnimatedList
для Firestore).
В целом это работа.
Но при отображении аватара пользователя появляется мерцание (Icons.account_circle
)).Например, иногда он показывает дополнительные Icon
(неверно), а затем не показывает (правильно).
Так что я думаю, возможно, это из-за перестройки виджета?Но я не знаю, как решить.
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,
onTap: _removeMessage,
),
);
},
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'];
}
Кто-нибудь поможет?Спасибо!