title: How to get ByteData from Image without referencing a file
body: <p>There are several ways of retrieving ByteData from network image or file, however I haven't found one where an existing Image in memory (or cache) can be converted into ByteData.</p>
  
  <p>Specifically referring to :</p>
  
  <pre><code>var resizedImage = ResizeImage(img.image, height: 28, width: 28);
  </code></pre>
  
  <p>For example, both the following answers assume there is a file:</p>
  
  <p><a href="https://stackoverflow.com/questions/55464761/how-to-load-image-widgets-from-bytedata-in-flutter">How to load Image widgets from ByteData in Flutter</a></p>
  
  <p><a href="https://stackoverflow.com/questions/53182480/how-to-get-a-flutter-uint8list-from-a-network-image">How to get a Flutter Uint8List from a Network Image?</a></p>
  
  <p>There is a toByteData method from dart.ui, but that also requires the image to come from a raw data.</p>
  
  <p>According to ResizeImage documentation, it's stored in cache, But I can't access it without using cache manager. </p>
  
  <blockquote>
    <p>The cached image will be directly decoded and stored at the resolution defined by width and height. The image will lose detail and use less memory if resized to a size smaller than the native size.</p>
  </blockquote>
  
  <p>I've used path_provider to get temporary directory, but it seems empty when resize image is executed. Is there anyway to convert image into ByteData without having the image in a path? </p>