1

How to convert an image from a url to base 64? I'm currently receiving the image by this code

return Image.network(imguUrl,
      width: 220.0, height: 220.0, fit: BoxFit.fill);

I want to get the base 64 for the image in target url. If anyone know how to do this please help.

Suthura Sudharaka
  • 643
  • 10
  • 25
  • i wonder why would you want to get that base64 for, what is the reason for that? why do you want to enlarge your data size by another 33%? – pskink Feb 07 '20 at 16:09
  • @pskink I want to save that in my database. In my case I don't care about the size for now. Do you know how to do this. – Suthura Sudharaka Feb 07 '20 at 16:14
  • 1
    https://flutter.dev/docs/cookbook/networking/fetch-data – pskink Feb 07 '20 at 16:16
  • @pskink this is for json in my url it's an image – Suthura Sudharaka Feb 07 '20 at 16:17
  • `Image.network` is for rendering an image into a widget, and as such will return the widget, not the image itself. If you are wanting to get the image data, you would be better off making the network call yourself to `imguUrl`. – Abion47 Feb 07 '20 at 16:56

1 Answers1

0

sorry for late response, you can use the http package and check this answer for complete example, hope it helps you.

Nazarudin
  • 917
  • 8
  • 26