dart - Flutter 中的装饰图像模糊

标签 dart flutter

我的应用背景设置如下:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Container(
        decoration: new BoxDecoration(
          image: new DecorationImage(
            image: new ExactAssetImage('assets/lol/aatrox.jpg'),
            fit: BoxFit.cover,
          ),
        ),
        child: new BackdropFilter(filter: new ImageFilter.blur(sigmaX: 600.0, sigmaY: 1000.0)),
        width: 400.0,
      ),
    );
  }
}

我想模糊 DecorationImage,所以我在 Container 中添加了一个 BackdropFilter,但我没有看到任何变化。我做错了什么?

最佳答案

您可以通过模糊容器子代来执行类似的操作。

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Container(
        decoration: new BoxDecoration(
          image: new DecorationImage(
            image: new ExactAssetImage('assets/dog.png'),
            fit: BoxFit.cover,
          ),
        ),
        child: new BackdropFilter(
          filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
          child: new Container(
            decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)),
          ),
        ),
      ),
    );
  }
}

screenshot

关于dart - Flutter 中的装饰图像模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49055676/

相关文章:

Gridview限制子内容

flutter - 从 parent 那里再次运行 future

flutter - 热重装时不刷新Flutter全局变量

list - 对列表的多个子列表进行排序以创建新列表,Dart

flutter - Flutter-包含来自SQFlite的数据的即时过滤器(搜索)ListView

Flutter TextField 的 Controller 根本不更新字段

dart - 'StreamSubscription<LocationData >' cannot be assigned to ' StreamSubscription<Map<String, double>>'

firebase - 使用 whereIn : List is not working 进行 Flutter Firestore 查询

flutter - 完成文本输入后,Flutter TextFormField调用值更改方法

Flutter 检查 wlan 是否激活