I have a simple upload to firebase storage function
Future uploadFile() async {
final path = 'selfies/${photo!.name}';
final file = File(photo!.path);
final ref = FirebaseStorage.instance.ref().child(path);
ref.putFile(file);
}
I am just wondering what the difference is when I'm calling it in a button i.e.
child: ElevatedButton(
onPressed: uploadFile,
}
child: ElevatedButton(
onPressed: () {
uploadFile();
},
)
And why does this not work?
child: ElevatedButton(
onPressed: uploadFile(),
}
I tried googling but can't find relevant results because I'm probably googling the wrong terms.