3
votes

i read this post convert image to base64 with flutter but this is about converting image file to base64. How to convert online url to base64.

Right now i can think of one solution that is to store image in path and get that file path and convert it. thats how this post showing.

is there any other sort way to convert online image uri to base64?

1

1 Answers

-1
votes

Well to convert the image you need the image data otherwise there's nothing to convert. So the step for the most effecient would be.

  1. Perform get request to the image url

  2. Read all the bytes from the response body

  3. Convert to base64

  4. Save the base 64 string locally or use how you please.

You don't have to save it. Just keep in mind if the user closes the app or it stops at any point during this process you'll have to start it from the beginning because you're not saving the image to disk.