-1

I have saved images as FileImage in my docs. i want to upload them to firebase storage. But it throws the error that type String can not be converted into type File. here is my code.

 String localImage = gg['path1']['path2']['path3'];//this is actually a fileimage inform of a string

          File ll = File(localImage);

          String downloadUrl = await FirebaseStorageHelper()
              .uploadImageAndGetDownloadUrl(
                  image: ll, uid: FirebaseAuth.instance.currentUser.uid);

          
        }

Update, i tried this code. But it throws existsSync Error

 FileImage localImage =
              FileImage(io.File(gg['path1']['path2]['path3']));

          
          print(localImage.file.absolute.existsSync());

Please help, I couldn't find anything useful on google

Rohan
  • 55
  • 5

1 Answers1

1

Try this.

it may be because you haven't converted it into a uri.

Uri myUri = Uri.parse(gg['path1']['path2']['path3']);
        File ff = File.fromUri(myUri);

Madhavam Shahi
  • 1,166
  • 6
  • 17