Error cannot provide both a color and a decoration in Flutter container

0 votes

Hi Guys,

I have one Container in Flutter code. Inside this code, I have used the BoxDecoration method. But Flutter BoxDecoration’s background color overrides the Container's background color. I have attached the script below.

new Container(
  color: Colors.pink,
  decoration: new BoxDecoration(
    borderRadius: new BorderRadius.circular(16.0),
    color: Colors.green,
  ),
);
Jul 29, 2020 in Others by akhtar
• 38,240 points
1,750 views

1 answer to this question.

0 votes

Hi@akhtar,

The color and decoration arguments cannot both be supplied, since it would potentially result in the decoration drawing over the background color. To supply a decoration with color, you can use the below code.

decoration: BoxDecoration(color: color).
answered Jul 29, 2020 by MD
• 95,340 points

Related Questions In Others

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,340 points
3,003 views
0 votes
1 answer

How to add a border in a Container in Flutter?

Hi@MD, By default, you can't see any border ...READ MORE

answered Sep 10, 2020 in Others by akhtar
• 38,240 points
2,091 views
0 votes
1 answer
0 votes
0 answers

Can we write AES enryption in Javascript and Decryption in Java using a static SALT and IV

I'm working on AES encryption I want to ...READ MORE

Jun 4, 2019 in Others by Eighteen
• 120 points
1,274 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,240 points
334 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,340 points
468 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,340 points
803 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,340 points
648 views
0 votes
1 answer

Create a container widget that consumes total space in Flutter.

Hi@akhtar, Instead of giving width and height value, ...READ MORE

answered Jul 28, 2020 in Others by MD
• 95,340 points
335 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP