這是我的代碼。這會產生一個矩形影像。
return Container(
width: 325,
height: 245,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
child: FadeInImage.assetNetwork(
placeholder: AppAssets.eventPlaceholder,
image: tempPhoto,
fit: BoxFit.cover,
),
);
我希望照片的角落會被剪掉,因為父母有圓角。
uj5u.com熱心網友回復:
您可以用 a 包裹小部件ClipRRect以獲得圓角:
使用圓角矩形剪輯其子項的小部件。
在你的情況下:
return ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
width: 325,
height: 250,
color: AppColors.white,
child: FadeInImage.assetNetwork(
placeholder: AppAssets.eventPlaceholder,
image: tempPhoto,
fit: BoxFit.cover,
),
),
);
- 這是 Google 團隊解釋的 YouTube 視頻
ClipRRect。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/498050.html
下一篇:圖片在網頁上加載非常緩慢
