I have this Function:
<code> Future<void> listImages(String childcode) async {
firebase_storage.ListResult result =
await firebase_storage.FirebaseStorage.instance.ref('/images/$childcode').listAll();
result.items.forEach((firebase_storage.Reference ref) {
String bilderName = ref.name;
print('Files: $ref');
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text(
"Images",
),
content: Row(
children: [
Container(
height: 200,
width: 200,
child: ImageViewer(childcode: childcode, fileName: bilderName),
),
],
),
actions: [
// Cancel Button
TextButton(
child: const Text("Close",
style: TextStyle(color: Colors.white),
),
onPressed: () => Navigator.pop(context),
),
],
),
);
});
}
</code>
<code> Future<void> listImages(String childcode) async {
firebase_storage.ListResult result =
await firebase_storage.FirebaseStorage.instance.ref('/images/$childcode').listAll();
result.items.forEach((firebase_storage.Reference ref) {
String bilderName = ref.name;
print('Files: $ref');
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text(
"Images",
),
content: Row(
children: [
Container(
height: 200,
width: 200,
child: ImageViewer(childcode: childcode, fileName: bilderName),
),
],
),
actions: [
// Cancel Button
TextButton(
child: const Text("Close",
style: TextStyle(color: Colors.white),
),
onPressed: () => Navigator.pop(context),
),
],
),
);
});
}
</code>
Future<void> listImages(String childcode) async {
firebase_storage.ListResult result =
await firebase_storage.FirebaseStorage.instance.ref('/images/$childcode').listAll();
result.items.forEach((firebase_storage.Reference ref) {
String bilderName = ref.name;
print('Files: $ref');
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text(
"Images",
),
content: Row(
children: [
Container(
height: 200,
width: 200,
child: ImageViewer(childcode: childcode, fileName: bilderName),
),
],
),
actions: [
// Cancel Button
TextButton(
child: const Text("Close",
style: TextStyle(color: Colors.white),
),
onPressed: () => Navigator.pop(context),
),
],
),
);
});
}
Its works and shows all Images from “/images/$childcode” in the firestore storage.
But it opens for every image one “Dialog” what is the only way i know to show the images.
So, how i can show them like a gallery in the UI?
I’ve tried to get the names from the images (bilderName) but can’t return them/ dont’t know how to get them outside the function.. tahnks!
ImageViewer:
<code>FutureBuilder(
future: storage.downloadURL('$formattedDate/$childcode/$fileName'),
builder: (BuildContext context,
AsyncSnapshot<String> snapshot) {
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData){
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100,
height: 100,
child: Image.network(
snapshot.data!,
fit: BoxFit.cover,
),
),
);
}
if (snapshot.connectionState == ConnectionState.waiting || !snapshot.hasData) {
return CircularProgressIndicator();
}
return Container();
}
),
</code>
<code>FutureBuilder(
future: storage.downloadURL('$formattedDate/$childcode/$fileName'),
builder: (BuildContext context,
AsyncSnapshot<String> snapshot) {
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData){
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100,
height: 100,
child: Image.network(
snapshot.data!,
fit: BoxFit.cover,
),
),
);
}
if (snapshot.connectionState == ConnectionState.waiting || !snapshot.hasData) {
return CircularProgressIndicator();
}
return Container();
}
),
</code>
FutureBuilder(
future: storage.downloadURL('$formattedDate/$childcode/$fileName'),
builder: (BuildContext context,
AsyncSnapshot<String> snapshot) {
if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData){
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 100,
height: 100,
child: Image.network(
snapshot.data!,
fit: BoxFit.cover,
),
),
);
}
if (snapshot.connectionState == ConnectionState.waiting || !snapshot.hasData) {
return CircularProgressIndicator();
}
return Container();
}
),