Zeffry Reynando
Zeffry Reynando

Reputation: 3899

Flutter : fetch image from picture Directory

I'm working with saved image from Url with Gallery Saver. Everything it's oke , i can insert image from URL, but i don't know how to fetch image from picture Directory .

It's different about getApplicationDocumentsDirectory() or getExternalStorageDirectory() ?

I want to display the image that was just saved.

Any solution ?

Save image Code :

void _testSaveImage() async {
    String path = "${Urls.BASE_API_IMAGE}/berita/${widget.gambarBerita}";
    GallerySaver.saveImage(path).then((bool success) {
      print('Success add image $path');
    }).catchError((onError) {
      print('Error add image $path');
    });
  }

Location Image saved

Image Location

Upvotes: 1

Views: 2385

Answers (2)

Andre Cytryn
Andre Cytryn

Reputation: 2705

Then just return the path you have and use a Image.file() widget to display it, lets say you have a Column():

Column(children: <Widget>[
  [...]
  Text('Here is my image:'),
  if (path.isNotEmpty && path != null)
    SizedBox(
      height: 200,
      width: 200,
      child: Image.file(File(path),
    ),
  Text('Caption of the image'),
  [...]
),

Docs for Image class here

Upvotes: 1

Quick learner
Quick learner

Reputation: 11457

Load local saved images using path and use it

var file = new File('path');
Image.file(file )

Upvotes: 0

Related Questions