in my programme i want to call the same path inside a methode called getPhoto()=>upload(statefulwidget) to other file or statefulwidget
Future getPhoto() async{
FirebaseFirestore fearbase = FirebaseFirestore.instance;
Reference ref=FirebaseStorage.instance
.ref()
.child("${widget.user}/ProfileData")
.child("Url_$postId");
await ref.putFile(file!);
downloadUrl=await ref.getDownloadURL();
// upload image to firestore
var list=[];
await fearbase.collection("users").doc(widget.user)
.collection("PostData").doc(ido)
.set({"PostUrl":downloadUrl,"ownerName":loggedInUser.username,"userId":loggedInUser.uid,"timestemp":postId,"PostId":ido,"like":FieldValue
.arrayUnion(list)})
.whenComplete(() => Fluttertoast.showToast(msg: "Image Uploaded successfully .i."));
// .then((DocumentReference ido) => ido.update({"PostId":ido.id}))
}
more specifically i want to get like field path from the other file
2
Answers
There are multiple ways to do this.
But the simple one is you can create a class and define this method within the class.
Then your can access it like
You can use callback function to solve this.
In usage, you can pass the function as follows
Or