如何在Flutter BoxDecoration中显示来自网络的图像? [英] How to show image from network in flutter BoxDecoration?

查看:558
本文介绍了如何在Flutter BoxDecoration中显示来自网络的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在BoxDecoration中显示网络的图像.但是它显示错误

I want to show an image of the network in BoxDecoration. But its showing error

不能将参数类型'image'分配给参数类型'imageProvider'".

"The argument type 'image' can't be assigned to the parameter type 'imageProvider'".

这是我尝试从盒子装饰中的网络显示图像的代码.请检查并让我知道此代码中的错误之处.

Here is the code where I am trying to show an image from the network inside box decoration. Please check and do let me know where I am wrong in this code.

decoration: new BoxDecoration(
    image: new DecorationImage(image: new Image.network("http://myurl.com/"+productList[index].thumbnail),
    fit: BoxFit.cover)
),

推荐答案

我已经解决了该问题,可以使用此代码实现.

I've resolved the issue, it can be achieved using this code.

decoration: BoxDecoration(
      image: DecorationImage(image: NetworkImage("urlImage"),
      fit: BoxFit.cover)
    ),

这篇关于如何在Flutter BoxDecoration中显示来自网络的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆