Reputation: 2295
I am trying to use ListTiles as items of the horizontal ListView.
final brandsWidget = SizedBox(
height: 200,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
ListTile(
leading: Image.asset('img_1.png'),
title: Text('Product 1'),
subtitle: Text('\$5'),
),
ListTile(
leading: Image.asset('img_1.png),
title: Text('Product 2'),
subtitle: Text('\$3'),
)
],
),
);
I got the following error:
Another exception was thrown: BoxConstraints forces an infinite width.
Exception caught by rendering library.
BoxConstraints forces an infinite width.
The relevant error-causing widget was ListTile
Upvotes: 3
Views: 4122
Reputation: 1636
You can uses ListTile
widget by wrapping it with Container
or SizedBox widget.
Error Explanation:
You are getting this error because ListTiles
have infinite width
. If you don't give them a proper one they will surely generate such errors.
Upvotes: 6