Edit: in your case you should do this:
PageView(
children: List.generate(cake.length 1, (index) {
if (index == cake.length) {
return Container(
width: 100,
height: 100,
color: Colors.grey,
child: const Icon(Icons.add),
);
} else {
final cakeData = cake[index];
return ListView(
children: [
Column(
children: [Text('add')],
),
],
);
}
}),
)
CodePudding user response:
ListView.builder
with horizontal scrolling
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
height: 100,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 4,
itemBuilder: (context, index){
return Padding(
padding: EdgeInsets.all(10.0),
child: InkWell(
child: Container(
width: 150,
color: Colors.yellow,
),
),
);
},
),
),
),
);
}