How to use BoxDecoration to a Container widget to draw an image

0 votes

Hi Guys,

I am new in Flutter design. I want to use one image in a container widget using BoxDecoration. How can I do that?

Aug 9, 2020 in Others by akhtar
• 38,170 points
3,164 views

1 answer to this question.

0 votes

Hi@akhtar,

The BoxDecoration class provides a variety of ways to draw a box. The box has a border, a body, and may cast a boxShadow. The shape of the box can be a circle or a rectangle. If it is a rectangle, then the borderRadius property controls the roundness of the corners. The following applies a BoxDecoration to a Container widget to draw an image of an owl with a thick black border and rounded corners.

Container( 
decoration: BoxDecoration( 
color: const Color(0xff7c94b6), 
image: const DecorationImage( 
image: NetworkImage('https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg'), 
fit: BoxFit.cover, ), 
border: Border.all( color: Colors.black, width: 8, ), 
borderRadius: BorderRadius.circular(12), ), )
answered Aug 9, 2020 by MD
• 95,180 points

Related Questions In Others

0 votes
0 answers

how to list the contents of a asset into an event

May 29, 2019 in Others by anonymous
106 views
0 votes
0 answers

How to open a new tab or a new window while writing an exam in AI - Onlime Remote Proctored

How to open a new tab or ...READ MORE

Jul 20, 2020 in Others by vimalkamal
• 120 points
1,612 views
0 votes
1 answer

How to set margin for a Container in Flutter?

Hi@akhtar, Margin property is used to set empty ...READ MORE

answered Jul 29, 2020 in Others by MD
• 95,180 points
990 views
0 votes
1 answer

How to use Card Widget in Flutter App?

Hi@akhtar, A card is a sheet of material used to ...READ MORE

answered Aug 26, 2020 in Others by MD
• 95,180 points
160 views
0 votes
1 answer

What is the future of flutter?

Hi@MD, Flutter is a rather new cross-platform framework ...READ MORE

answered Jul 17, 2020 in Others by akhtar
• 38,170 points
163 views
0 votes
1 answer

What is Flutter?

Hi@akhtar, Flutter is an app SDK for building ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,180 points
257 views
0 votes
1 answer

How to install Flutter in Windows system?

Hi@akhtar, You can follow the below-given steps to ...READ MORE

answered Jul 17, 2020 in Others by MD
• 95,180 points
435 views
0 votes
1 answer

How to create a container widget in Flutter?

Hi@akhtar, Container means a parent widget that contains ...READ MORE

answered Jul 28, 2020 in Others by MD
• 95,180 points
234 views
0 votes
1 answer

How to add a border to a widget in Flutter?

Hi@akhtar, You need to add the TextField as a child to a Container that has ...READ MORE

answered Jul 24, 2020 in Others by MD
• 95,180 points
764 views