我正在尝试将ListTiles作为水平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'),
)
],
),
);
我得到了以下错误:
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
ListTile
包裹在SizedBox
中。 - undefined