Flutter Error: RangeError (index): Invalid value: Not in range 0..2, inclusive: 3

后端 未结 5 1821
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 00:49

I am using a long list in flutter. All the items are rendering fine but also following error :

RangeError (index): Invalid value: Not in range 0..2, inclusive: 3         


        
5条回答
  •  天涯浪人
    2021-02-05 01:27

    if you are using StreamBuilder then you must use this line of code

      StreamBuilder(
                      stream: FirebaseFirestore.instance.collection("Tooth")
                      .orderBy("date", descending: false).snapshots() ,
                    
                      builder: (BuildContext context, AsyncSnapshot snapshot){
                     
                        if(snapshot.hasData)
                        {
                          return ListView.builder(
                            itemCount: snapshot.data.docs.length,
                              padding: const EdgeInsets.only( top: 20.0),
                            itemBuilder: (BuildContext context, int index) {
                               DocumentSnapshot ds = snapshot.data.docs[index];
     },
                          );
                        }
                       
                      },
                    ),
    

提交回复
热议问题