title: How to resolve it "RangeError (index): Invalid value : Valid value range is empty : 0" in flutter?
body: <p><a href="https://i.stack.imgur.com/1L99i.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1L99i.jpg" alt="enter image description here"></a></p>
  
  <p>I'm to trying to get images from firestore database and put onto String type list and want to show as the slider Image.
  but the above error is occurring on Screen but after milliseconds, error goes and images show as slider</p>
  
  <p><strong>Decleared Global Varible:</strong></p>
  
  <pre><code> List&lt;String&gt; getSliderImages=[];
  </code></pre>
  
  <p><strong>Method for fetched images from firestore:</strong></p>
  
  <p>And this method is calling inside <code>initState()</code> method</p>
  
  <pre><code> void getSliderImage(){
     List&lt;String&gt; userId=[];
      Firestore.instance.collection("Slider").getDocuments()
      .then((QuerySnapshot snapshot) {
        snapshot.documents.forEach((f){
          setState(() {
           userId.add(f.documentID);  
          });
        });
  
  
        for(int i=0;i&lt;userId.length;i++){
          setState(() {
           print('snap.documentID_IF_userId :${userId[i]}');
           Firestore.instance.collection('Slider').document(userId[i]).get().then((DocumentSnapshot document){
            String image=document['Image'];
            getSliderImages.add(image); 
            print('snap.documentID_IF_userId_IMAGE :$image');
            print("getSliderImages:$getSliderImages");
           });
          });
        } 
      }).catchError((onError){
        print(onError); 
        setState(() {
        Fluttertoast.showToast(msg: "$onError"); 
        });
      });
    }
  </code></pre>
  
  <p><strong>Slider widget, there I want to display images:</strong></p>
  
  <p>Here I used <a href="https://pub.dev/packages/carousel_pro" rel="nofollow noreferrer">carousel_pro</a> plugin for Slider</p>
  
  <pre><code>Container(
                  padding: const EdgeInsets.all(10.0),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.all(Radius.circular(30.0)),
                  //color: Colors.black
                ),
                height: MediaQuery.of(context).size.height/5,
                width: MediaQuery.of(context).size.height/2,
                child: Carousel(
                  images: [
                     new NetworkImage(getSliderImages[0]),
                     new NetworkImage(getSliderImages[1]),
                     new NetworkImage(getSliderImages[2]),
                     new NetworkImage(getSliderImages[3]),
  
                    ],//getSliderUserId
                  showIndicator: true,
                  borderRadius: true,
  
                  moveIndicatorFromBottom: 100.0,
                 noRadiusForIndicator: false,
                  overlayShadow: false,
                 overlayShadowColors: Colors.white,
                  overlayShadowSize: 0.7,
               )
              ),
  
  </code></pre>