简体   繁体   English

为什么我会遇到这个错误 RangeError (index): Invalid value: Valid value range is empty?

[英]Why im gettin this error RangeError (index): Invalid value: Valid value range is empty?

IM getting an error when using streambuilde and I cannot really figure out why. IM 在使用 streambuilde 时出现错误,我无法真正弄清楚原因。 heres the error这是错误

RangeError (index): Invalid value: Valid value range is empty: 0
The relevant error-causing widget was
StreamBuilder<QuerySnapshot>
lib/chatmessenger/recent_conversations_page.dart:49

And heres my code这是我的代码

 @override
  Widget build(BuildContext context) {
    var firestore = FirebaseFirestore.instance;
    return Container(
      height: 50,
      width: widget._width,
      child: StreamBuilder<List<ConversationSnippet>>(
        stream: DatbaseService.instance.getUserConversations(user.uid),
        builder: (_context, _snapshot) {
          var _data = _snapshot.data;
          if (_data != null) {
            _data.removeWhere((_c) {
              return _c.timestamp == null;
            });
            if (_snapshot.data.isNotEmpty) {
              return ListView.builder(
                itemCount: _data.length,
                itemBuilder: (_context, _index) {
                  return StreamBuilder(.  here is the error thrownnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
                      stream: firestore
                          .collection('meinprofilsettings')
                          .where('uid', isEqualTo: _data[_index].uid)
                          .snapshots(),
                        
                      builder: (context, snapshot) {
                         DocumentSnapshot video =
                                      snapshot.data.docs[_index];
                         
                        return ListTile(
                          onTap: () {
                         
                          },
                          title: Text(video.data()['username']),

I marked in the code where the error is thrown and also you can see that I use the Documetnsnaoshot video in for the text in title.我在代码中标记了引发错误的位置,您还可以看到我使用了 Documetnsnaoshot 视频作为标题中的文本。 When im removing the Documetnsnapshot video the error is away.当我删除 Documetnsnapshot 视频时,错误消失了。 If you need more information please leave ac comment.如果您需要更多信息,请留下交流评论。 What I do is getting the data of streambuilder and then create inside this a new streambuikder where I fetch data from firebase with the uid.我所做的是获取streambuilder的数据,然后在其中创建一个新的streambuikder,我使用uid从firebase获取数据。 And last but not least I wanna display these data.最后但并非最不重要的一点是,我想显示这些数据。

So heres my firebase所以这是我的 firebase 在此处输入图像描述

And the doc id is the field _data[_index].uid.文档 id 是字段 _data[_index].uid。 So this works.but what I need instead of the field 'uid' is the doc id of the collection "meinprfosilsettings " Heres the picture所以这行得通。但是我需要的是集合“meinprfosilsettings”的文档ID而不是字段“uid”这是图片

在此处输入图像描述

IM getting an error when using streambuilde and I cannot really figure out why. IM 在使用 streambuilde 时出现错误,我无法真正弄清楚原因。 heres the error这是错误

RangeError (index): Invalid value: Valid value range is empty: 0
The relevant error-causing widget was
StreamBuilder<QuerySnapshot>
lib/chatmessenger/recent_conversations_page.dart:49

And heres my code这是我的代码

 @override
  Widget build(BuildContext context) {
    var firestore = FirebaseFirestore.instance;
    return Container(
      height: 50,
      width: widget._width,
      child: StreamBuilder<List<ConversationSnippet>>(
        stream: DatbaseService.instance.getUserConversations(user.uid),
        builder: (_context, _snapshot) {
          var _data = _snapshot.data;
          if (_data != null) {
            _data.removeWhere((_c) {
              return _c.timestamp == null;
            });
            if (_snapshot.data.isNotEmpty) {
              return ListView.builder(
                itemCount: _data.length,
                itemBuilder: (_context, _index) {
                  return StreamBuilder(.  here is the error thrownnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
                      stream: firestore
                          .collection('meinprofilsettings')
                          .where('uid', isEqualTo: _data[_index].uid)
                          .snapshots(),
                        
                      builder: (context, snapshot) {
                         DocumentSnapshot video =
                                      snapshot.data.docs[_index];
                         
                        return ListTile(
                          onTap: () {
                         
                          },
                          title: Text(video.data()['username']),

I marked in the code where the error is thrown and also you can see that I use the Documetnsnaoshot video in for the text in title.我在代码中标记了引发错误的位置,您还可以看到我使用了 Documetnsnaoshot 视频作为标题中的文本。 When im removing the Documetnsnapshot video the error is away.当我删除 Documetnsnapshot 视频时,错误消失了。 If you need more information please leave ac comment.如果您需要更多信息,请留下交流评论。 What I do is getting the data of streambuilder and then create inside this a new streambuikder where I fetch data from firebase with the uid.我所做的是获取streambuilder的数据,然后在其中创建一个新的streambuikder,我使用uid从firebase获取数据。 And last but not least I wanna display these data.最后但并非最不重要的一点是,我想显示这些数据。

So heres my firebase所以这是我的 firebase 在此处输入图像描述

And the doc id is the field _data[_index].uid.文档 id 是字段 _data[_index].uid。 So this works.but what I need instead of the field 'uid' is the doc id of the collection "meinprfosilsettings " Heres the picture所以这行得通。但是我需要的是集合“meinprfosilsettings”的文档ID而不是字段“uid”这是图片

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 StreamProvider - RangeError(索引):无效值:有效值范围为空:0 - StreamProvider - RangeError (index): Invalid value: Valid value range is empty: 0 RangeError(索引):无效值:有效值范围为空:0 | Flutter Firebase - RangeError (index): Invalid value: Valid value range is empty: 0 | Flutter Firebase rangeerror(索引):无效值:有效值范围为空:flutter 从 firebase 获取数据时为 0 - rangeerror (index): invalid value: valid value range is empty: 0 in flutter while getting data from firebase 如何解决 flutter 中的“RangeError (index): Invalid value: Valid value range is empty: 0”? - How to resolve it “RangeError (index): Invalid value : Valid value range is empty : 0” in flutter? 在我的 Flutter 应用程序中,从 firebase 获取产品时显示 RangeError(索引):无效值:有效值范围为空:0 - In My Flutter Application while Fetching products from firebase showing RangeError (index): Invalid value: Valid value range is empty: 0 RangeError(索引):无效值:不在0..5范围内(包括6):Flutter SliverChildBuilderDelegate - RangeError (index): Invalid value: Not in range 0..5, inclusive: 6 : Flutter SliverChildBuilderDelegate 为什么“RangeError:无效状态代码:0”,firebase 函数 - Why "RangeError: Invalid status code: 0", firebase functions 错误:参数“documentPath”的值不是有效的资源路径。 路径必须是非空字符串 - Error: Value for argument “documentPath” is not a valid resource path. Path must be a non-empty string 错误:参数“documentPath”的值不是有效的资源路径。 路径必须是非空 string。 /*什么是空的或者不是字符串*/ - Error: Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string. /*what is empty or not a string*/ 错误:参数“data”的值不是有效的 Firestore 文档 - Error: Value for argument “data” is not a valid Firestore document
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM