imageflutter

How to show image from network in flutter BoxDecoration?


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

"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)
),

Solution

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

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