美文网首页Flutter
Flutter Material 圆角不显示问题

Flutter Material 圆角不显示问题

作者: 哦呵呵y | 来源:发表于2020-04-11 15:31 被阅读0次
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

图片不显示圆角的原因是因为Material没有对子部件进行裁剪,多出来的部分依然会显示。直接给Material添加一个裁剪属性就OK了,clipBehavior: Clip.hardEdge,

相关文章

网友评论

    本文标题:Flutter Material 圆角不显示问题

    本文链接:https://www.haomeiwen.com/subject/xnoymhtx.html