Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List flift/Dart/Firestore-在动画列表中按天分组文档_List_Dart_Flutter_Google Cloud Firestore_Grouping - Fatal编程技术网

List flift/Dart/Firestore-在动画列表中按天分组文档

List flift/Dart/Firestore-在动画列表中按天分组文档,list,dart,flutter,google-cloud-firestore,grouping,List,Dart,Flutter,Google Cloud Firestore,Grouping,如何按天在用户之间分组消息?到目前为止,它只是添加到列表中并按天排序,但我似乎无法在过去几天发送的消息之间添加间隔。列表显示在AnimatedList()中 代码: List<Message> _messages = []; ... _initMessages() { // Being called in the initState APIs().chats.messages( chatID: widget.chat.chatID, onEmpty: ()

如何按天在用户之间分组消息?到目前为止,它只是添加到列表中并按天排序,但我似乎无法在过去几天发送的消息之间添加间隔。列表显示在
AnimatedList()中

代码:

List<Message> _messages = [];

... 

_initMessages() { // Being called in the initState
  APIs().chats.messages(
    chatID: widget.chat.chatID,
    onEmpty: () {
      if (mounted)
        setState(() {
          this._isLoading = false;
        });
    },
    onAdded: (m) {
      if (mounted)
        setState(() {
          if (m.type == 'Image') {
            m.message = NetworkImage(m.message);
          }
          this._messages.add(m);
          this._messages.sort((a, b) => a.createdAt.compareTo(b.createdAt));
          if (mounted) this._listKey.currentState.insertItem(this._messages.length, duration: Duration(milliseconds: 500));
          this._isLoading = false;
        });


    },
    onModified: (m) {
      int i = this._messages.indexWhere((message) => message.messageID == m.messageID);
      if (mounted)
        setState(() {
          this._messages[i] = m;
          this._messages.sort((a, b) => a.createdAt.compareTo(b.createdAt));
          this._isLoading = false;
        });
    },
    onRemoved: (m) {
      int i = this._messages.indexWhere((message) => message.messageID == m.messageID);
      if (mounted)
        setState(() {
          this._messages.removeAt(i);
          this._messages.sort((a, b) => a.createdAt.compareTo(b.createdAt));
          this._isLoading = false;
        });
    },
    onFailure: (e) {
      print(e);
    });
}
这是一个分为两部分的问题,将文档按天分组,并尝试使其在
动画列表中工作。日期为Firestore时间戳类型

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: 'package:flutter/src/widgets/animated_list.dart': Failed assertion: line 279 pos 12: 'itemIndex >= 0 && itemIndex <= _itemsCount': is not true.