Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 容器don'中的子级图像;不要跟随集装箱边界_Flutter - Fatal编程技术网

Flutter 容器don'中的子级图像;不要跟随集装箱边界

Flutter 容器don'中的子级图像;不要跟随集装箱边界,flutter,Flutter,问题是图像边缘是可见的,并且不遵循我为容器设置的边界 容器( 装饰:盒子装饰( 颜色:颜色。灰色[900], borderRadius:borderRadius.all(半径圆形(24.0)), ), 孩子:图像( 图像:网络图像(thisSongInfo.albumImageUrl), 适合:BoxFit.cover, 颜色:颜色。黑色87, colorBlendMode:BlendMode.darken, ), ), fit:BoxFit.contain修复了边缘问题,但这不包括容器尝试使

问题是图像边缘是可见的,并且不遵循我为容器设置的边界

容器(
装饰:盒子装饰(
颜色:颜色。灰色[900],
borderRadius:borderRadius.all(半径圆形(24.0)),
),
孩子:图像(
图像:网络图像(thisSongInfo.albumImageUrl),
适合:BoxFit.cover,
颜色:颜色。黑色87,
colorBlendMode:BlendMode.darken,
),
),

fit:BoxFit.contain修复了边缘问题,但这不包括容器

尝试使用
ClipRRect
包装图像,有关文档的详细信息请参见此处 ,

请尝试以下代码:

Container(
                      decoration: BoxDecoration(
                        color: Colors.grey[900]
                      ),
                      child: ClipRRect(
                          borderRadius: BorderRadius.all(Radius.circular(24.0)),
                          child: Image(
                            image: NetworkImage(thisSongInfo.albumImageUrl),
                            fit: BoxFit.cover,
                            color: Colors.black87,
                            colorBlendMode: BlendMode.darken,
                          )),
                    )

如果您想要圆角图像,可以使用
“ClipRRect”
小部件

ClipRRect(
              borderRadius: BorderRadius.circular(10),
              child:  Image(
                image: NetworkImage(thisSongInfo.albumImageUrl),
                fit: BoxFit.cover,
                color: Colors.black87,
                colorBlendMode: BlendMode.darken,
              ),
         )

尝试对容器进行前端装饰,而不是装饰尝试为容器添加高度和宽度。如果它回答了您的问题,请接受作为答案,这样搜索此问题的人也会知道,其他人也不会费心寻找其他解决方案。谢谢