how to convert an image to base64 image in flutter? : <p>I am actually trying to convert an image picked by <code>ImagePicker</code> in flutter to <code>base64</code> image. I am always getting the error. </p>

<pre><code>FileSystemException: Cannot open file, path = 
'file:///storage/emulated/0/Download/Abid_Wipro_neemuchwala1- 
770x433.jpg' (OS Error: No such file or directory, errno = 2)
E/flutter ( 5042): #0      _File.throwIfError 
(dart:io/file_impl.dart:628)
E/flutter ( 5042): #1      _File.openSync 
(dart:io/file_impl.dart:472)
E/flutter ( 5042): #2      _File.readAsBytesSync 
(dart:io/file_impl.dart:532)
</code></pre>

<p>the code i am using is this one.</p>

<pre><code>     File fileData;
   /////////////...........


      new Container(
            child: new FutureBuilder&lt;File&gt;(
              future: imageFile,
              builder: (BuildContext context, AsyncSnapshot&lt;File&gt; snapshot) {
                if (snapshot.connectionState == ConnectionState.done &amp;&amp;
                    snapshot.data != null) {
                  fileData = snapshot.data;


                  return new Container(
                    height: MediaQuery.of(context).size.height / 2,
                    width: MediaQuery.of(context).size.width,
                    margin: const EdgeInsets.all(4.0),
                    decoration: new BoxDecoration(
                      image: new DecorationImage(
                        image: new FileImage(snapshot.data,),
                        fit: BoxFit.cover
                      ),
                    ),
                  );
                } else if (snapshot.error != null) {
                  return new Column(children: &lt;Widget&gt;[
                    centerWidget('Choose Image or Audio or Video'),
                    _circleAvatar()
                  ]);
                } else {
                  return new Column(children: &lt;Widget&gt;[
                    centerWidget('Choose Image or Audio or Video'),
                    _circleAvatar()
                  ]);
                }
              },
            ),
          ),
/////////////////

    File imageFile = new File(widget.fileData.uri.toString());
    List&lt;int&gt; imageBytes = imageFile.readAsBytesSync();
    String base64Image = base64Encode(imageBytes);
</code></pre>

<p>Please, can someone tell me where is it that i am making a mistake .</p>

<p>Many thanks,
Mahi</p>
