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) ),
To load an image from network using NetworkImage , pass the image URL as the argument of NetworkImage . Then, pass the NetworkImage as the image argument of DecorationImage . Below is the URL of the image used in this tutorial.
File f = File("https://example.com/xyz.jpg"); The whole point is to get the image from the given URL and save it as a File variable.
I've resolved the issue, it can be achieved using this code.
decoration: BoxDecoration( image: DecorationImage(image: NetworkImage("urlImage"), fit: BoxFit.cover) ),
if you want to load CachedNetworkImage then use in this way *** https://pub.dev/packages/cached_network_image
CachedNetworkImage( imageUrl: "http://via.placeholder.com/200x150", imageBuilder: (context, imageProvider) => Container( decoration: BoxDecoration( image: DecorationImage( image: imageProvider, fit: BoxFit.cover, colorFilter: ColorFilter.mode(Colors.red, BlendMode.colorBurn)), ), ), placeholder: (context, url) => CircularProgressIndicator(), errorWidget: (context, url, error) => Icon(Icons.error), ),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With