I am trying to get data from Firestore Database and Firestore Storage. I am getting text data from Firestore Database collections but I am not able to get images from Firestore Storage. Its giving Exception. I should use Download URLs : To request a download URL, call the getDownloadURL method on a reference. Can anyone guide me where and how I can use it and get images. https://firebase.flutter.dev/docs/storage/usage/#download-urls
Following is code ;
StreamBuilder<QuerySnapshot>(
stream: db.collection('running').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return StaggeredGridView.countBuilder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
crossAxisCount: 2,
itemCount: snapshot.data!.docs.length,
mainAxisSpacing: 5.0,
crossAxisSpacing: 20.0,
itemBuilder: (context, index) {
DocumentSnapshot ds = snapshot.data!.docs[index];
final shoes = Shoes.runningShoes[index];
return Column(
children: [
Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
color: Color(0xffF6F6F6)),
child: Column(
children: [
SizedBox(height: 60.0),
Image.network(
'https://firebasestorage.googleapis.com/v0/b/shoes-app-e2319.appspot.com/o/${ds['image']}',
width:
MediaQuery.of(context).size.width,
),
Align(
child: Padding(
padding: const EdgeInsets.only(
right: 16.0),
child: Image.network(
'https://firebasestorage.googleapis.com/v0/b/shoes-app-e2319.appspot.com/o/${ds['logo']}',
height: 60,
width: 40,
color: Color(0xffCBCBCB),
),
),
alignment: Alignment.bottomRight),
],
)),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Text(
'\$${ds['price']}',
textScaleFactor: 1.5,
style: TextStyle(
fontWeight: FontWeight.w500),
),
FavoriteButton(valueChanged: () {})
],
),
),
Flexible(
child: Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Align(
alignment: Alignment.topLeft,
child: Text(
ds['name'],
style: TextStyle(fontSize: 18.0),
),
),
))
],
);
},
staggeredTileBuilder: (index) {
return StaggeredTile.count(
1, index.isEven ? 2.1 : 2.2);
});
} else if (snapshot.hasError) {
return CircularProgressIndicator();
} else {
return CircularProgressIndicator();
}
},
)



