title: flutter : RangeError (index): Invalid value: Valid value range is empty:
body: <pre><code>class PictureBox extends StatefulWidget {
    int num;
    PictureBox({Key key, this.num}): super(key:key);
  
    @override
    _PictureBoxState createState() =&gt; _PictureBoxState();
  }
  
  var _writeprofile = writeprofileState();
  
  class _PictureBoxState extends State&lt;PictureBox&gt; {
    @override
    void initState() {
      super.initState();
    }
  
  
    @override
    Widget build(BuildContext context) {
      return Container(
        child: InkWell(
          onTap: () async {
            print('asddd1');
            var getimage =
                await ImagePicker.pickImage(source: ImageSource.gallery);
            setState(() {
              tmpimage = getimage;
              imageBytes = getimage.readAsBytesSync();
              image64 = base64Encode(imageBytes);
              print(tmp64list.length);
              print('Image Path $tmpimage');
            });
            tmp64list[widget.num] = image64;
          },
  </code></pre>
  
  <p>'tmp64list[widget.num] = image64;' That has been error since.</p>
  
  <p>I wanted put through the index of the list</p>
  
  <p>Like this :</p>
  
  <pre><code>PictureBox pictureBox1 = PictureBox(num:1);
  PictureBox pictureBox2 = PictureBox(num:2);
  PictureBox pictureBox3 = PictureBox(num:3);
  PictureBox pictureBox4 = PictureBox(num:4);
  PictureBox pictureBox5 = PictureBox(num:5);
  PictureBox pictureBox6 = PictureBox(num:6);
  </code></pre>
  
  <p>But my intention is not running, but appear error.</p>
  
  <p>error :</p>
  
  <pre><code>Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 3
  #0      List._setIndexed (dart:core-patch/growable_array.dart:153:72)
  #1      List.[]= (dart:core-patch/growable_array.dart:150:5)
  </code></pre>
  
  <p>i think so, because initState in stateful</p>
  
  <p>right ?</p>
  
  <p>but i can't solve because i don't understand enough about flutter</p>
  
  <p>can you help me ? </p>