我正在嘗試更改影像高度,但它沒有改變。
這是我的代碼
ListTile(
leading: ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.network(
book.urlImage,
fit: BoxFit.cover,
width: 55,
height: 90,
),
),
uj5u.com熱心網友回復:
默認情況下,ListTile's最大前導小部件高度為 56 像素。
這是的源代碼ListTile,
final Offset baseDensity = visualDensity.baseSizeAdjustment;
if (isOneLine)
return (isDense ? 48.0 : 56.0) baseDensity.dy;
if (isTwoLine)
return (isDense ? 64.0 : 72.0) baseDensity.dy;
return (isDense ? 76.0 : 88.0) baseDensity.dy;
您可以看到每個條件的前導小部件的最大高度。90px 是不可能的。如果 90px 是你想要的,那么考慮ListTile用Row和制作你自己的Column。
uj5u.com熱心網友回復:
您是否嘗試過將 Listtile 放入容器中?
就這樣-->
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/horoscopes/${horoscope.toLowerCase()}.png'),
),
borderRadius: const BorderRadius.all(
Radius.circular(25.0),
),
),
),
uj5u.com熱心網友回復:
在 SizedBox 子項中設定您的影像
SizedBox(
width: 50,
height: 90,
child: Image.network(
book.urlImage,
fit: BoxFit.cover,
),
)
uj5u.com熱心網友回復:
試試下面的代碼希望對你有幫助。
ListTile(
leading: Container(
width: 150.0,
height: 100.0,
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade500,
),
image: DecorationImage(
image: NetworkImage(
'https://tech.pelmorex.com/wp-content/uploads/2020/10/flutter.png',
),
),
//shape: BoxShape.circle,
),
),
),
您的結果螢屏-> 
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/354039.html
上一篇:如何在flutter中顯示來自api回應的png影像?
下一篇:P5無法加載CSV表和影像
