Material(
borderRadius: BorderRadius.circular(12.0),
elevation: 14.0,
shadowColor: Colors.grey.withOpacity(0.5),
child: Stack(
children: <Widget>[
AspectRatio(
aspectRatio: 16 / 9,
child: Image.network(
posts[index].imageUrl,
fit: BoxFit.cover,
),
),
Positioned(
top: 32.0,
left: 32.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
posts[index].title,
style: TextStyle(fontSize: 20.0, color: Colors.white),
),
Text(
posts[index].author,
style: TextStyle(fontSize: 13.0, color: Colors.white),
),
],
),
),
],
),
),
image.png
圖片不顯示圓角的原因是因?yàn)镸aterial沒有對子部件進(jìn)行裁剪粘姜,多出來的部分依然會顯示妈踊。直接給Material添加一個裁剪屬性就OK了蒸眠,clipBehavior: Clip.hardEdge,