错误状态:DocumentSnapshotPlatform 中不存在字段 //Flutter

时间:2021-05-31 19:52:14

标签: firebase flutter android-studio google-cloud-firestore mobile-application

_ref = FirebaseFirestore.instance .collection('conversations/${widget.conversationId}/messages');

我之前尝试过针对此主题提出的问题的解决方案,但没有帮助。这就是为什么我想再问一次。我该如何解决这个错误?我的代码是这样的:

StreamBuilder(
              stream: _ref.snapshots(),
              builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
                return (!snapshot.hasData)
                    ? CircularProgressIndicator()
                    : ListView(
                        children: snapshot.data.docs
                            .map(
                              (DocumentSnapshot document) => ListTile(
                                title: Align(
                                  alignment: widget.userId ==
                                          document[
                                              'senderId'] // I have tried document.data()['senderId] but didn't work
                                      ? Alignment.centerLeft
                                      : Alignment.centerRight,
                                  child: Container(
                                    padding: EdgeInsets.all(8),
                                    decoration: BoxDecoration(
                                      borderRadius: BorderRadius.horizontal(
                                          left: Radius.circular(10),
                                          right: Radius.circular(10)),
                                      color: Theme.of(context).primaryColor,
                                    ),
                                    child: Text("Trying Message"),
                                  ),
                                ),
                              ),
                            )
                            .toList(),
                      );
              },
            ),

0 个答案:

没有答案