带有flutter的Firebase聊天问题。消息位置根据需要工作

时间:2019-03-21 08:29:12

标签: flutter

我正在使用此代码将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),存在问题
如果您遇到同样的问题,请回答。

0 个答案:

没有答案