Home > other >  how to get the path of Asset picked from gallery multi_image_picker2?
how to get the path of Asset picked from gallery multi_image_picker2?

Time:01-20

I am using multi_image_picker2: ^5.0.2. I just need to upload the selected images to Firebase. How can i get the path of List ? when i use image.name i get the issue:

'file.absolute.existsSync()': is not true.

.

The Code Is:

  var images = <Asset>[].obs;
  await FirebaseStorage.instance
        .ref('products/$docID')
        .putFile(File(images[0].name??""));

CodePudding user response:

You can use pickedFilename.path

var images = <Asset>[].obs;
 var img= await FirebaseStorage.instance
        .ref('products/$docID')
        .putFile(File(images[0].name??""));

var imgPath=img.path;

CodePudding user response:

if (productImage1 != null) {
        final storageReference =
            FirebaseStorage.instance.ref().child("products/imgname");

        final uploadTask = storageReference.putFile(productImage1!);
        final downloadUrl = await uploadTask.whenComplete(() => null);
        imgUrl = await downloadUrl.ref.getDownloadURL();
      }

Here productImage1 contains the path after selecting the image. productImage1 = imagefile.path;

  •  Tags:  
  • Related