title: How to convert image from path to Base64 in flutter?
body: <p>I'm trying to capture an image, then send path of the image to a function that returns the image in Base64. For capturing an image I'm using the example on Flutter website.</p>
  
  <pre><code>Future _takePhoto(BuildContext context) async {
    try {
      await _initializeControllerFuture;
  
      final path = join(
        (await getTemporaryDirectory()).path,
        '${DateTime.now()}.png',
      );
  
      await _cameraController.takePicture(path);
  
      setState(() {
        _imagePath = path;
      });
  
    } catch (e) {
      print(e);
    }
  }
  </code></pre>
  
  <p>It's working well. I can see the captured image in widget <code>Image.file(File(_imagePath))</code></p>
  
  <p>The problem starts when I'm trying to convert the image into Base64.</p>
  
  <pre><code>File file = File(_imagePath);
  final _imageFile = ImageProcess.decodeImage(
    file.readAsBytesSync(),
  );
  
  String base64Image = base64Encode(ImageProcess.encodePng(_imageFile));
  print(base64Image);
  </code></pre>
  
  <p>I copy and paste the printed message into an online tool that generates an image from Base64 and either it's all black or there is tiny top layer of the image and the rest is black.</p>