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,210 points
1,076 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,300 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,300 points
1,560 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,210 points
1,661 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 3, 2019 in Others by Eighteen
• 120 points
1,168 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,210 points
219 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,300 points
342 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,300 points
533 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,300 points
362 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,300 points
250 views