简体   繁体   中英

How to cache image from was s3 url in flutter

I had a AWS S3 image url.I want to cache the image once its downloaded in my flutter app,How can I achieve that

You can use CachedNetworkImage

CachedNetworkImage(
  imageUrl: 'https://your.url',
  progressIndicatorBuilder: (context, url, progress) => Center(child: CircularProgressIndicator()),
  height: MediaQuery.of(context).size.height * 0.1,
  placeholder: (context, url) => Image.asset('images/NoImage.png'),
),

Or if you want to store image on your device than you can use sqflite and store image to database as Uint8List or String bytes. Image widget has method Image.memory for get image from Uint8List which stored on your database

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM