dart - 如何装饰Image.file

标签 dart flutter

我想使文件图像模糊并在其中添加半径。

这是我的代码:

BackdropFilter(
        filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
        child: new Container(
          width: width * 0.55,
          height: height * 0.70,
          decoration: new BoxDecoration(

            //this is not accepted becuse Image.file is not ImageProvider
            image: new DecorationImage(
                image: new Image.file(new File(messageSnapshot.value['file'])),
                fit: BoxFit.cover
            ),

            borderRadius: new BorderRadius.all(new Radius.circular(10.0)),
          ),
          child: Center(child: new CircularProgressIndicator(backgroundColor: Colors.deepPurpleAccent,)),
        ),
      )

如何使用 Image.file 小部件实现此目的?

最佳答案

使用 FileImage 图像提供程序代替 Image.File 小部件

new DecorationImage(
  image: new FileImage(yourFile),
  fit: BoxFit.cover,
);

关于dart - 如何装饰Image.file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52621749/

相关文章:

flutter - 我可以使用 Dart 在 Flutter 中将数据写入 Apple HealthKit/Google-fit

flutter - 具有动态宽度的Flutter水平gridview

firebase - 如何使用 Flutter 执行 Firebase 可变事务数据?

firebase - 我如何使用从其他页面获取的值

flutter - 使用 SliverAppBar flutter 设计这个动画

dart - 将 Future<List<int>> 传递到 Button 中的快照

dart - Flutter阻止ListView重新呈现其子级

android - 如何以编程方式卸载应用程序?

dart - Flutter image_picker post上传图片

flutter - 在 Dart 的列表中使用 map 或 for 循环有什么不同吗?