1

i use package image_downloader for download svg image. i want to save them in asset file project. can anyone help me please how can I do that ? image_downloader: ^0.31.0

here is my code:

  downloadSvg(url, name)async{
    await ImageDownloader.downloadImage(url,
      destination: AndroidDestinationType.custom(directory: 'E:/projects/Myapp/assets/icons')
        ..inExternalFilesDir()
        ..subDirectory("icons/$name.svg"),
    );
  }
user17838882
  • 93
  • 2
  • 14

1 Answers1

1

That's not possible you can't save it to your asset file dynamically to flutter the app at run time.

You need to save that file to the user device or you can use any local storage packages for that. for example, you can use shared_preferences , flutter_secure_storage

One should only use assets to store files which shall remain common for all users.

Kishan Busa
  • 821
  • 6
  • 14
  • actually, I want to download SVG and replace it with a file in my asset. it's not possible? – user17838882 Apr 23 '22 at 10:24
  • No, you can't do any modifications to your asset file. You can save that file to local storage and then access or modify it or you can preCache file. – Kishan Busa Apr 23 '22 at 10:27