ko2ic / image_downloader

Flutter plugin that downloads images and movies on the Internet and saves to Photo Library on iOS or specified directory on Android.
https://pub.dartlang.org/packages/image_downloader#-readme-tab-
MIT License
92 stars 115 forks source link

Assets Floder image Download #64

Closed jvapps21 closed 4 years ago

jvapps21 commented 4 years ago

i want to download image from assets: folder image . how can do this using your library?. currently it just download image from URL only ..

jvapps21 commented 4 years ago

After number of days searching and learning flutter i found solution Using Path Provider Package

RaisedButton( child: Text("Download Image"), onPressed: () async { final Fname = "image_1"; final ByteData bytes = await rootBundle.load('assets/images/' + Fname); final buffer = bytes.buffer; var dir = await getTemporaryDirectory(); File(dir.path+"/"+Fname).writeAsBytes(buffer.asUint8List(bytes.offsetInBytes, bytes.lengthInBytes)); final fpath = dir.path.toString() + "/" + Fname; print("stored Path ===>"+fpath); }
)

You can also give your own specific path too for stored assets folder / Url image as well