Home > Software engineering >  Flutter - display image from storage and data from db
Flutter - display image from storage and data from db

Time:12-30

I'm trying to do an app in flutter that display some info about a restaurant from a DB, and for each restaurant an image of it. How can I do that? I was trying to use s3 from aws to store the images but I don't know how to save the reference of that image into my db without make the access to the bucket public. Can anyone helps me please?

CodePudding user response:

u can use cached_network_image plugin

Here is package link https://pub.dev/packages/cached_network_image

use this widget like this:-

CachedNetworkImage(
        imageUrl: "http://via.placeholder.com/350x150",
        placeholder: // place holder image
        errorWidget: Container(), // use container or any other widget to avoid cross line issue in image
     ),

CodePudding user response:

There has some way to do this. You can simply use this package which I am mention below: https://pub.dev/packages/cached_network_image

Or you can use the Image widget which provided my flutter. I share some simple code:

NB: If you using asset images then use asset. Image.asset('assets/images/background_image.jpg',fit: BoxFit.cover,height: 400,)

Image.network('imageUrl',fit: BoxFit.cover,height: 400,)

  • Related