在图像上添加磨砂玻璃效果

时间:2019-10-06 08:21:58

标签: flutter dart

我正在尝试在图像上添加毛玻璃效果,根据我的研究,以下似乎是解决问题的一种方法。但是,虽然没有棉绒,但它给了我运行时错误:“无法同时提供颜色和装饰”。有没有更好的方法来模糊背景并带有橙色磨砂效果?

 return Consumer<UserModel>(
  builder: (context, model, _) => Scaffold(
    body: Container(
      color: Colors.orange.withOpacity(0.75),
        decoration: BoxDecoration(
          image: DecorationImage(
            alignment: Alignment.bottomCenter,
            image: AssetImage("assets/images/pngguru.com-id-bnwsh.png"),
            fit: BoxFit.cover,
          ),
        ),

1 个答案:

答案 0 :(得分:0)

这意味着,如果您的BoxDecoration中有一个container属性,则需要将color移到BoxDecoration内部

喜欢

Container(
    decoration: BoxDecoration(
      color: Colors.orange.withOpacity(0.75), // <-------------
      image: DecorationImage(
        alignment: Alignment.bottomCenter,
        image: AssetImage("assets/images/pngguru.com-id-bnwsh.png"),
        fit: BoxFit.cover,
      ),
    )