![](/img/trans.png)
[英]How to use ListTileTheme to style ListTile inside ListView?
[英]How to use ListTile inside horizontal ListView in Flutter?
我正在嘗試使用 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
您可以通過用Container
或SizedBox widget.
包裝它來使用ListTile
小SizedBox widget.
錯誤解釋:
您收到此錯誤是因為ListTiles
具有infinite width
。 如果你不給他們一個合適的,他們肯定會產生這樣的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.