I don't have a photo that should be in the background of the application, but it doesn't display anything for me, and in the error it writes something about the link
I searched for information, and I found a code that I recycled, here it is below, it is in the general class:
late String imageUrl;
final storage = FirebaseStorage.instance;
@override
void initState() {
super.initState();
imageUrl = "";
getImageUrl();
}
Future<void> getImageUrl() async {
final ref = storage.ref().child("");
final url = await ref.getDownloadURL();
setState(() {
imageUrl = url;
});
}
And this is part of the code that overlays the photo on the background:
body: Stack(
children: [
Image(
image: NetworkImage(imageUrl),
fit: BoxFit.cover,
width: double.infinity,
height: double.infinity,
),
)
Follow these steps:
getImageUrlmethod, you have an empty string insideref().child(""). This means you're not specifying the path to the image in Firebase Storage. Make sure to provide the correct path to the image.Replace
"path/to/your/image.jpg"with the actual path to your image in Firebase Storage.By adding error handling, you'll be able to see any errors that occur during the process, which can help in diagnosing the issue.
Check the printed URL in the console to ensure it's correct and accessible.