我正在使用此代码将https://github.com/josancamon19/flutter_chat_app用于聊天应用程序,但是应用程序消息位置无法像其他聊天应用程序消息那样按需工作。
一段时间后,消息索引有时会上涨。
child: FirebaseAnimatedList(
reverse: true,
sort: (a, b) => b.key.compareTo(a.key),
query: secretchatref,
itemBuilder: (_, DataSnapshot data, Animation<double> animation, int index) {
String name = data.value['username'];
ChatMessage message = new ChatMessage.fromSnapshot(
data,
animation,
data.value['username'] == widget.myname
? TextDirection.rtl
: TextDirection.ltr,
name);
return message;
}),
我认为这行sort: (a, b) => b.key.compareTo(a.key),
存在问题
如果您遇到同样的问题,请回答。