I want my list item in the middle of the ListView
@override Widget build(BuildContext context)
{
List<String> listName = ['Woody', 'Buzz', 'Rex'];
return Container
(
decoration: BoxDecoration(border: Border.all(color: Colors.pinkAccent)),
width: 400,
height: 700,
alignment: Alignment.centerLeft,
child: ListView.builder
(
itemCount: listName.length,
itemBuilder: (context, index)
{
return OurName(listName[index]);
},
),
);
}
This is when I use shrinkWrap, when I scroll up it's cut off and it can't be scroll down
shrinkWrap
This is what I expected expected
The key to your issue is the shrinkWrap property of ListView. So to fix this you can do something like this:
Container(
alignment: Alignment.centerLeft,
child: ListView.builder(
itemBuilder: (context, index) {
return Text("The index$index");
},
shrinkWrap: true,
itemCount: 30,
),
),
For me works this code!
@override
Widget build(BuildContext context) {
return Container(
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
child: ListView.builder(
shrinkWrap: true,
itemCount:rows.length,
itemBuilder: (
context,
index,
) {
return ...;
}),
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With