简体   繁体   English

Flutter 中的模糊图像

[英]Blur Image in Flutter

I am new to flutter.我是新来的。 I want to make a .png image blurry in flutter which is in a container.我想在容器中使 .png 图像模糊不清。 For that I used the below mentioned code.为此,我使用了下面提到的代码。 But the blur effect is applied to the whole screen.但模糊效果应用于整个屏幕。

I used the following code :我使用了以下代码:

child: Container(
                  padding: EdgeInsets.only(
                  left: 18, right: 18, top: 7, bottom: 7),
                  width: _width,

                  child: Stack(
                    children : [ 
                      Image.asset('assets/classes.png',
                            fit: BoxFit.fitWidth,
                            ),
                      Positioned.fill(
                        child: BackdropFilter(
                          filter: ImageFilter.blur(sigmaX: 4,sigmaY: 4),
                          child: Container(color: Colors.white.withOpacity(0.5)),
                          )
                        )
                    ]
                    ),

                ),
              ),
            ]),
          ),
        ),
      ),
    ]),

Check this package in pub.devpub.dev中检查这个包

https://pub.dev/packages/blur https://pub.dev/packages/blur

Also, you could find a good solution in the answers to this question:此外,您可以在这个问题的答案中找到一个很好的解决方案:

Blurred Decoration Image in Flutter Flutter 中的装饰图像模糊

我相信图像应该是背景滤镜的孩子

you can use simple "glassy" library.您可以使用简单的“玻璃”库。 https://pub.dev/packages/glassy https://pub.dev/packages/glassy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM