I want to make horizontal scrollable images widget. I placed pageview for that but it is neither working nor I got any error. Don't know what to do.
Map<String, dynamic> documentData = snapshot.data.data();
//List of images
List imageList = documentData["images"];
return ListView(
padding: EdgeInsets.all(0),
children: [
Container(
height: 400,
child: PageView(
children: [
for (var i = 0; i < imageList.length; i++)
Container(
child: Image.network(
"${imageList[i]}",
fit: BoxFit.cover,
))
],
)),
These new containers created in the for loop wasn't added to the list of children. Use spread operator or PageView.builder instead. Example:
PageView.builder(
itemcount: imageList.length,
itemBuilder:(BuildContext context, int index ){
return Container(
child: Image.network(
"${imageList[index]}",
fit: BoxFit.cover,
));
},
),
OR
PageView(
children: [
for (var i = 0; i < imageList.length; i++)
...[Container(
child: Image.network(
"${imageList[i]}",
fit: BoxFit.cover,
)),]
],
)