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,260 points
5,696 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,460 points

Related Questions In Others

0 votes
2 answers

How to set margin for a Container in Flutter?

Container( margin: const EdgeInsets.fromLTRB(20, 10, 20, ...READ MORE

answered Apr 17, 2023 in Others by anonymous
9,323 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,260 points
3,225 views
0 votes
1 answer

How to make an error flagging array in VBA and translate all array elements as a string message?

In my opinion, using an array in ...READ MORE

answered Mar 17, 2023 in Others by Kithuzzz
• 38,000 points
542 views
0 votes
1 answer

How to automatically assign a color to the maximum and minimum values in a set of selected cells in Excel?

See Conditional Formatting, which may be accessed ...READ MORE

answered Apr 7, 2023 in Others by Kithuzzz
• 38,000 points
570 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,260 points
1,184 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,460 points
1,499 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,460 points
1,806 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,460 points
2,251 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,460 points
1,485 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP