Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert image url to XFile in Flutter?

Tags:

flutter

dart

I'm facing a problem from the server I'm getting the image url data as a string. I need to save all these urls in the XFile format list. Tell me how can I convert the image url to XFile format?

I get

enter image description here

like image 853
Max Avatar asked Dec 01 '25 11:12

Max


1 Answers

Try this:

static Future<XFile> getImageXFileByUrl(String url) async {
    var file = await DefaultCacheManager().getSingleFile(url);
    XFile result = await XFile(file.path);
    return result;
  }
like image 80
Nitzan Eliyahu Avatar answered Dec 03 '25 14:12

Nitzan Eliyahu