RangeError(索引):无效值:有效值范围为空:0,Firebase

时间:2020-04-29 03:07:09

标签: flutter dart google-cloud-firestore

![ this is the database that I want to consult, the user has information, but in the query he shows me that the information is null] 1 我正在尝试根据上述查询的结果来获取Firestore用户的信息,我正在尝试使用FutureBuilder,但是它给了我以下错误 RangeError(索引):无效值:有效值范围为空:0,

这是代码

StreamBuilder(


 stream: Firestore.instance.collection('partner_requests')
                            .document(user.uid)
                            .collection(user.uid)
                            .snapshots(),
                            builder: (_, snapshot) {
                                if (!snapshot.hasData) {
                                    return Center(
                                       child: CircularProgressIndicator());
                                } else {
                                    return ListView.builder(
                                        itemCount: snapshot.data.documents.length,
                                        itemBuilder: (BuildContext context, index) {
                                            DocumentSnapshot partnerRequests = snapshot.data.documents[index];
                                            return Column(
                                                children: < Widget > [
                                                    SizedBox(
                                                        height: 20.0,
                                                    ),
                                                    FutureBuilder(
                                                        future: Firestore.instance.collection('users')
                                                        .document('${partnerRequests['sender_uid ']}')
                                                        .collection('${partnerRequests.data['sender_uid ']}')
                                                        .getDocuments(),
                                                        builder: (BuildContext context, AsyncSnapshot snap) {
                                                            if (snap.hasData) {
                                                                if (snap.data != null) {
                                                                    return Card(
                                                                        child: ListTile(
                                                                            leading: CircleAvatar(
                                                                                backgroundImage: NetworkImage('${snap.data.documents.toList()[0].data["photo_url"].toString()}'),
                                                                            ),
                                                                        ),
                                                                    );

                                                                } else {
                                                                    return Container();
                                                                }
                                                            } else {
                                                                return CircularProgressIndicator();
                                                            }
                                                        }),
                                                ],
                                            );
                                        });
                                }
                            }
                        ),

0 个答案:

没有答案