I'm having an issue with base name as I look to official documentation of basename and everything seems to me "ok". But it still shows errors on basename. Thank you for your time!
Errors Error with basename: The expression doesn't evaluate to a function, so it can't be invoked Local variable 'basename' can't be referenced before it is declared.
Code Snippet
Future uploadImageToFirebase(BuildContext context) async {
String basename = basename(_imageFile.path);
StorageReference firebaseStorageRef =
FirebaseStorage.instance.ref().child('uploads/$basename');
StorageUploadTask uploadTask = firebaseStorageRef.putFile(_imageFile);
StorageTaskSnapshot taskSnapshot = await uploadTask.onComplete;
taskSnapshot.ref.getDownloadURL().then(
(value) => print("Done: $value"),
);
}
context part code snippet
void addToFb() async {
final User user = FirebaseAuth.instance.currentUser;
...
dbRef.add({
...
}).then((res) {
isLoading = false;
Navigator.pushReplacement(
context, <--- HERE I GOT AND ERROR
MaterialPageRoute(builder: (context) => Home(uid: widget.uid)),
);
}).catchError(
(err) {
showDialog(
context: context, <--- HERE I GOT AND ERROR
builder: (BuildContext context) {
return AlertDialog(
title: Text("Error"),
content: Text(err.message),
actions: [
...
],
);
},
...
}