I am going to store an image in firebase storage. When I send file through image picker then its working fine. But when I manually pass link of image then it is showing an error that says:
'package:firebase_storage/src/storage_reference.dart':
Failed assertion: line 62 pos 12: 'file.existsSync()': is not true.
I am writing following code:
File image = File("assets/img/pic.jpg");
final StorageReference firebaseStorageRef =
FirebaseStorage.instance.ref().child('image');
InkWell(
child: Text("Tap to Upload"),
onTap: () {
firebaseStorageRef.putFile(image);
},
),
File
with assets as they aren't real files. If you want to upload an asset, load the asset into memory usingRootBundle
then useputData
instead ofputFile
. – Execrative