Reputation: 129
I want to display a downloaded image from a temporary directory
I've tried other ways on how to do it but i can't seem to get it to work. In the below example I've tried with Image.asset() but that won't work either because it can't be assigned to Image Provider.
var dir = Directory.systemTemp;
final String name = data['file_name'];
final String path = "${dir.path}/$name";
BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
image: DecorationImage(
fit: BoxFit.cover,
image: Image.asset(path)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.7),
offset: new Offset(offset / 2, offset),
blurRadius: blur,
)
]),
I just want my image to be displayed from custom directory
Upvotes: 0
Views: 845
Reputation: 8988
With the help of this package, you can get the path the path temporary and from directory path_provider
This is the way how you can utilize this:
final dir = await getApplicationDocumentsDirectory();
String imgDir = dir + "/your_directory";
In order to find files from the above directory, you can use listSync package.
final myDir = new Directory(imgDir);
List<FileSystemEntity> _images;
_images = myDir.listSync(recursive: true, followLinks: false);
I guess that'd solve your issue. Thanks
Upvotes: 2