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 \'i
Ammy's answer is right. However I would like to the answer my experience of using BoxDecoration().
To apply background image either from the Internet or from assets in Flutter app, we can use DecorationImage() class in image property of BoxDecoration().
Below is a code snippet, where background image is applied from an image from a URL in the Flutter app:
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage('https://www.exampledomain.com/images/background.jpg'),
fit: BoxFit.fill,
),
),
)
So, to apply background image in Container widget, we have to use decoration property. In the decoration property we supply a new BoxDecoration() object and this object should have an image property which points to the image resource URL. In the above snippet, image propery is instantiated a NetworkImage() object which is pointing to an image URL.